Fatal error: Call to a member function get_page_permastruct() on a non-object

The WordPress environment is not yet fully initialized when your plugin files are loaded, it’s almost always too early to safely run code that interacts with core at that point. WordPress achieves its initial state through a process which contains its own set of actions and filters, so plugins load before that happens to allow … Read more

How should I go about registering JavaScript that isn’t a file? [duplicate]

You can hook the wp_footer action to output arbitrary JavaScript. This the same action that WordPress uses to output footer enqueued scripts. Here’s an example that encapsulates the shortcode, data, and script output in a class: <?php /* Plugin Name: WPD_Example */ class WPD_Example_Plugin { public $data = array(); function __construct() { add_shortcode( ‘wpd_example’, array( … Read more

How to Move the Comments Bubble to the Right Side of the Toolbar

After you have removed the comments bubble, you add it again. The trick is that in the $args of add_node you have to set parent to top-secondary. So it will look like this: add_action( ‘admin_bar_menu’, ‘wpse227079_toolbar_link_to_bubble’, 999 ); function wpse227079_toolbar_link_to_bubble ( $wp_admin_bar ) { $args = array( ‘id’ => ‘wp-admin-bar-comments’, ‘parent’=> ‘top-secondary’, ‘title’ => ‘QQ’, … Read more

How to modify files inside wp-includes directory in wordpress

I wouldn’t recommending any core files. Instead, you can filter the title and make your changes, like so: add_filter( ‘document_title_parts’, function( $title ) ) { // $title is an array of parts if ( strlen( $title[‘title’] ) > 10 ) { $title[‘title’] = substr( $title[‘title’], 0, 5 ); // Show only first 5 characters } … Read more

Change WooCommerce Email Header using custom plugin

You have to remove action woocommmerce_email_header remove_action( ‘woocommerce_email_header’, ’email_header’); Which was registered at wp-content\plugins\woocommerce\includes\class-wc-emails.php Than add your own action add_action(‘woocommerce_email_header’,’your_function_name’); your function should output html default there is below code in header template <?php /** * Email Header * * This template can be overridden by copying it to yourtheme/woocommerce/emails/email-header.php. * * HOWEVER, on occasion … Read more