Getting “Cannot modify header information – headers already sent” error on wp-admin only whenever any plugin is activated

Error Diagnosis: The first Error: PHP Warning: An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href=”https://wordpress.org/support/”>support forums</a>. (WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.) in /Applications/MAMP/htdocs/site-url.com/wp-includes/update.php on line 306 This is basically … Read more

Custom endpoint and X-WP-TotalPages (headers)

I had a quick look and here’s how the headers are set in the WP_REST_Posts_Controller::get_items() method: $response = rest_ensure_response( $posts ); // … $response->header( ‘X-WP-Total’, (int) $total_posts ); $response->header( ‘X-WP-TotalPages’, (int) $max_pages ); // … return $response; where: $total_posts = $posts_query->found_posts; and we could use as @jshwlkr suggested: $max_pages = $posts_query->max_num_pages; You could emulate that … Read more

Is it safe to fix Access-Control-Allow-Origin (CORS origin) errors with a php header directive?

Yes, you open your site to being requested via AJAX to any other script in the whole web. It would be better if you limit the origin to one specific remote domain from which you are consuming the API, like this example: header(“Access-Control-Allow-Origin: http://mozilla.com”); However as the mozilla documentation states, a client can fork the … Read more

Disable h1 and h2 from rich text editor combobox

you can change lots of things about the tinyMCE editor at the tiny_mce_before_init filter. http://codex.wordpress.org/TinyMCE_Custom_Buttons the following will restrict your blockformats to p,h3,h4 and blockquote function wpa_45815($arr){ $arr[‘theme_advanced_blockformats’] = ‘p,h3,h4,blockquote’; return $arr; } add_filter(‘tiny_mce_before_init’, ‘wpa_45815’); EDIT for WordPress 3.9 see link function wpa_45815($arr){ $arr[‘block_formats’] = ‘Paragraph=p;Heading 3=h3;Heading 4=h4’; return $arr; } add_filter(‘tiny_mce_before_init’, ‘wpa_45815’);

disable wordpress canonical tag meta

found solution: before wp_head() command, insert: remove_action(‘wp_head’, ‘rel_canonical’); p.s. if generator meta tag is being added from elsewhere (i.e. from theme or plugin, rather than wp-core) and was priority other than 10, then you might need to put the exact priority, as is was given from that theme/plugin: i.e. remove_action(‘wp_head’, ‘rel_canonical’, 47);

How to remove rest api link: in http headers?

The output is generated by the rest_output_link_header(). This function is used in two actions, wp_head and template_redirect in default-filters.php:@line234. You can remove the function from those hooks to remove the output you wanted to remove. Put the following codes in your theme’s functions.php to achieve the desired result. remove_action( ‘wp_head’, ‘rest_output_link_wp_head’, 10); remove_action( ‘template_redirect’, ‘rest_output_link_header’, … Read more