How to overwrite / extent wordpress function is_email

is_email is a native WP function. As you can see here (https://core.trac.wordpress.org/browser/tags/5.0.3/src/wp-includes/formatting.php#L2886) it allows you to modify it with filter is_email. So yes – anytime the function is_email will be called, it will run, and at the end it will run your filters allowing you to modify the result. But… The filter should take 3 … Read more

Can I hide certain upload folders in media library [duplicate]

Perhaps a bit quick and dirty, but this should work: function media_library_hide_dlm_downloads($where) { if(isset($_POST[‘action’]) && ( $_POST[‘action’] == ‘query-attachments’)) { $where .= ‘ AND guid NOT LIKE “%wp-content/uploads/dlm_downloads%”‘; } return $where; } add_filter(‘posts_where’, ‘media_library_hide_dlm_downloads’); Read more about the posts_where filter.

Execute function after a post has been published

function check_meta( $post_id, $post, $update ) { $post_type = get_post_type($post_id); if ( “post” != $post_type ) return; $video_code_val = get_post_meta( $post_id, ‘video_code’, true ); // Check if the video_code field has a value. if ( ! empty( $video_code_val ) ){ //if it does, set post format set_post_format( $post_id, ‘video’ ); } } add_action( ‘save_post’, ‘check_meta’, … Read more

Auto delete post if certain custom field data is empty

kses_remove_filters(); $new_id = wp_insert_post($post_arr, true); kses_init_filters(); if (is_wp_error($new_id)) { $this->write_log(“error occurred in wordpress post entry: ” . $new_id->get_error_message() . ” ” . $new_id->get_error_code(), true); return; } if($url) update_post_meta($new_id, ‘source_link’, $url); else { // wp_delete_post($new_id); // Move post to trash $deleted = wp_delete_post($new_id, true); // Permanently delete post if(! $deleted ){ $this->write_log(“error deleting post entry.”, true); … Read more

Running a script before absolutely everything

init is not the first action to run on a WordPress install. Here is a basic rundown of a typical stack order. https://codex.wordpress.org/Plugin_API/Action_Reference Try hooking into `muplugins_loaded’. I don’t believe it is conditional, so it should run every time. https://codex.wordpress.org/Plugin_API/Action_Reference/muplugins_loaded <?php add_action( ‘muplugins_loaded’, ‘my_script’ ); function my_script() { // my script here }