How can the tinyMCE dom be manipulated (offical API does not seem to work)?

Hope You can use fallowing // Sets class attribute on all paragraphs in the active editor tinymce.activeEditor.dom.setAttrib(tinymce.activeEditor.dom.select(‘p’), ‘class’, ‘myclass’); // Sets class attribute on a specific element in the current page tinymce.dom.setAttrib(‘mydiv’, ‘class’, ‘myclass’); or You can add Id by jquery like this $(‘div’).find(‘p’).attr(‘id’, ‘myid’);

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

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

How to Make a Category Always Selected?

This can be done with jQuery. In this example, the modifier is printed when editing an existing post (admin_head-post.php) and when writing a new one (admin_head-post-new.php). There’s a condition to check for the correct post type, as this hooks work with posts, pages and custom post types. The “Most used” tab is being hidden. To … Read more

How to change post status in hook?

You get the full post object as a second parameter on save_post. Use it to change the status just like the following code. add_action( ‘save_post’, ‘wpse_78351_status’, 10, 2 ); function wpse_78351_status( $post_ID, $post ) { remove_filter( current_filter(), __FUNCTION__ ); if ( ‘trash’ !== $post->post_status ) //adjust the condition { $post->post_status=”draft”; // use any post status … Read more