How to get all images and their thumbnails from wp media library

Here’s what you can do. Get a list of all available thumbnail sizes Query all the attachments For each attachment size, get it’s URL and save it into the array Let’s change your code into this: function get_images_highcompress_data() { $args = array( ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image/jpeg,image/jpg,image/png’, ‘post_status’ => ‘inherit’, ‘posts_per_page’ => -1, ‘orderby’ … Read more

I can’t find where a hook is being defined in a plugin – Easy Digital Downloads

in includes/actions.php there’s function edd_post_actions() { $key = ! empty( $_POST[‘edd_action’] ) ? sanitize_key( $_POST[‘edd_action’] ) : false; if ( ! empty( $key ) ) { do_action( “edd_{$key}”, $_POST ); } } add_action( ‘init’, ‘edd_post_actions’ ); in templates/shortcode-profile-editor.php there’s ..input type=”hidden” name=”edd_action” value=”edit_user_profile” .. which, if the two are used together, would make do_action( ‘edd_edit_user_profile’, … Read more

Display a text message if the shortcode is not found?

do_shortcode() returns content with shortcodes filtered out. We can check the return value and display appropriate message accordingly. $output = do_shortcode( ‘[picu_list_collections email=”‘ . $current_user->user_email . ‘”]’ ); // the shortcode returns an empty <ul> tag, if there is no gallery // https://plugins.trac.wordpress.org/browser/picu/trunk/frontend/includes/picu-template-functions.php#L464 if($output == ‘<ul class=”picu-collection-list”></ul>’) echo “Nothing here”; else echo $output; I hope … Read more

How To Ignore a Filter On Applying Filter the Content In a Function

You can temporarily detach the function from the hook. // THIS IS MY PROBLEM LINE, i USE Apply Filters for post content…. $priority = has_filter(‘the_content’, [‘TableOfContents’, ‘writeTOC’] ); if ( $priority !== false ) remove_filter(‘the_content’, [‘TableOfContents’, ‘writeTOC’], $priority ); $meta = apply_filters(‘the_content’, $post->post_content); if ( $priority !== false ) add_filter(‘the_content’, [‘TableOfContents’, ‘writeTOC’], $priority ); $meta … Read more

How can I include a setting that has a variable number of values in a settings page using register_setting?

If you are using the Settings API correctly, you should be using the add_settings_field function. The 3rd argument in this function is for the callback function that will generate the HTML for the form field for the individual setting. The Codex states: Function that fills the field with the desired inputs as part of the … Read more

Retrieving custom fields with $wpdb->get_results

Note, before going further: Take care about portability and security: function wpse50056_get_post_meta() { global $wpdb; $results = $wpdb->get_results( ” SELECT ID, post_date, post_title, post_content, meta_key, meta_value FROM {$wpdb->posts} INNER JOIN {$wpdb->postmeta} ON ( $wpdb->posts.ID = {$wpdb->postmeta}.post_id ) ” ); foreach( $results as $result ) { printf( ‘<pre>%s</pre>’, htmlspecialchars( var_export( $result, true ) ) ); } … Read more

Problem with sorting entries in a plugin’s admin interface table

Figured this out myself after kaiser pointed me towards the appropriate entry on the Codex, specifically the part at http://codex.wordpress.org/Class_Reference/WP_List_Table#Notice:_Sortable_Columns which I’d managed to miss. Problem was with the get_sortable_columns method, which should look like this: public function get_sortable_columns() { return $sortable = array( ‘title’=>array(‘title’,true), ‘description’=>array(‘description’,true), ‘submissionDate’=>array(‘submissionDate’,true), ‘name’=>array(‘name’,true), ’email’=>array(’email’,true), ‘post_title’=>array(‘post_title’,true) ); } Guess the tutorial … Read more