Why won’t my preg_replace work with content_save_pre?

I copied your code to a file in my home directory on my Ubuntu box, removed the weird character that @s_ha_dum noticed, and ran it. It worked as I’d expect. Code: <?php function get_the_post_imgs($oldPostContent) { $newPostContent = $oldPostContent; $newPostContent = preg_replace_callback( “/<img.*src=[\”‘]([^\”‘]*)[\”‘].*>/i”, // pattern to match to (i.e the contents of an <img src=”https://wordpress.stackexchange.com/questions/140017/…” /> … Read more

apply_filters(‘the_content’) – make it ignore shortcodes?

The function that parses the shortcode, do_shortcode is added as a filter on the_content by default, at priority 11. You can remove it using remove_filter: remove_filter( ‘the_content’, ‘do_shortcode’, 11 ); Call this right before you’re actually using the_content, and add it afterwards (in the unlikely case that it’s needed after that): remove_filter( ‘the_content’, ‘do_shortcode’, 11 … Read more

add_filter does not work as expected

Your plugin code is going to run before the theme code and hence will run before anything is added to the hook. You will need to the code that processes the file inclusion to some other hook that runs after all of the plugins load, like after_setup_theme This should help: Is there a flowchart for … Read more

Variables in post title

Just use the the_title filter to hook into the title content and work with that. add_filter( ‘the_title’, function( $title ) { // Manipulate the $title as you want and then return that. // You can add test conditions such as ‘is_main_query’ // (https://codex.wordpress.org/Function_Reference/is_main_query) return $title; } );

Add Sortable Column For All Post Types

Why not get all post_types and loop through them with the filter. This should work if the callback for all post types is the same (managesortablecolumns). The code will look something like this: function init_managesortablecolumns (){ $post_types = get_post_types(); foreach( $post_types as $post_type ){ add_filter( ‘manage_edit-‘ . $post_type . ‘_sortable_columns’, ‘managesortablecolumns’ ); } } add_action( … Read more

Move a file from a directory to another

Can’t seem to track down the right filter to process this in just yet (where the edit form is being saved), especially since attachment_fields_to_edit can be used in multiple places. But maybe you already know? This will give you a good start anyway… add_filter(‘??attachment_fields_save_filter??’,’move_attachment_directory’,10,2); function move_attachment_directory($form_fields,$post) { $attach_id = $post->ID; if (!isset($_POST[‘attachments’][$attach_id][‘my_select’])) {return;} if ($_POST[‘attachments’][$attach_id][‘my_select’] … Read more

Change term name only on front

You can detect if you are in the frontend using the function is_admin(), like so: add_filter(‘get_term’, ‘filter_term_name’, 10, 2); function filter_term_name($term, $taxonomy) { // return the term untuched if you are in the admin if( is_admin() ) { return $term; } if ($taxonomy == ‘my-taxonomy’) { // numeric value of term in another taxonomy $meta_value … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)