How to set all external links to a certain domain to “nofollow”?

Assuming you are targetting links in post content, I’d say something like that : add_filter( ‘the_content’, ‘wpse_254317_nofollow’ ); /** * Add rel nofollow according to a predefined domain * to links in content * @param $content * @link http://stackoverflow.com/a/4809181/1930236 * @return mixed */ function wpse_254317_nofollow( $content ) { $my_folder = “https://google.com”; preg_match_all( ‘~<a.*>~isU’, $content, $matches … Read more

Seriously stuck with some custom meta box/plugin stuff

Here is a simple example that adds a meta box to all public post types: // All public post types $post_types = array_merge( array(‘page’ => ‘page’, ‘post’ => ‘post’), get_post_types(array(‘_builtin’ => FALSE)), ); // Add meta box for each post type foreach ($post_types as $post_type) { add_meta_box(‘id’, ‘title’, ‘callback’, $post_type); } WP Codex: get_post_types(), add_meta_box().

Make the css of the widget overwrite theme css

Is possible to make bootstrap css “contextualized” inside a selector, i.e. bootstrap styles works inside that selector, and thanks to css specificity rules, there them take precence over other rules. How to do: First of all download bootstrap less. Let’s assume that this files are in ‘bootstrap/less’ folder. Now create a new less file, let’s … Read more

Styles and Scripts, Selectively enqueue across entire site

Right I figured this out myself not sure how “hacky” this is but basically this is the code: public function filter_scripts_styles(){ if(is_page($this->plugin_name)){ //Same name is used for the style as the js file so can reuse this array $allowed = array(‘jquery’, $this->plugin_name.’_scrollpath’, $this->plugin_name); //Check Scripts First global $wp_scripts; foreach($wp_scripts->queue as $handle ) { if(!in_array($handle, $allowed)){ … Read more

Translate wordpress plugin [closed]

Do not create a PO file manually. The synchronization must be automatic, or you will waste much time. Each you change a string, you have to change it in two files now. Poedit has a built-in PHP parser. Use it to read your project files. And you don’t have to edit WPLANG to create a … Read more

Activating a single plugin via php

If you already have the plugin installed as part of the initial setup, you can add a loader for it in mu-plugins that activates it. Must-use plugins don’t require activation themselves, so adding a call to activate_plugin() inside it will attempt to automatically activate your plugin on every load. That becomes a problem if you … Read more

Subscribe2 Configuration

Sure it is joshau Thee S2 admin interface could be better, but it is stable, has been around a long time. You can exclude categories (eg all except your 2) and can allow users to select which categories they want from within that. I’m not the author, but I have it in use in a … Read more

Moving customized core code into plugins?

I’m under the assumption that WordPress will first look through all the functions in my plugins and if it finds one it won’t default to the WordPress core version of the function? No. Not counting any pluggable functions that might be added by a theme or plugin, the only functions that you can overwrite in … Read more