Ready to get started?Download WordPress


Media Tags
Row count fix [!] (3 posts)

  1. alx359
    Posted 3 years ago #

    I spent a lot of time debugging for this.

    - Assigning a new row count to Screen Options doesn't work in Media->Media-Tags page (3.2-RC3).
    - Proper WP hook to fix the lost of focus when clicking Media->Media-Tags. (Props to Dion Hulse [WP dev] for hinting the proper way to hook for this. Ref inside.)

    media-tags\mediatags_admin.php li ~315

    ////[alx359] Multiple fixes for the Media-Tags page
    	// Adds the 'Media-Tags' submenu option under the Media nav
    	add_media_page( _x("Media-Tags", 'menu label', MEDIA_TAGS_I18N_DOMAIN),
    					_x("Media-Tags", 'page label', MEDIA_TAGS_I18N_DOMAIN),
    					"edit-tags.php?taxonomy=media-tags" );
    	// Adds the 'Media-Tags' submenu option under the Media nav, but with a new post_type hook
    	// [http://wordpress.org/support/topic/adding-a-media-submenu-issues]
    	add_media_page('Media-Tags', 'Media-Tags', 'upload_files', "edit-tags.php?taxonomy=media-tags&post_type=attachment" );
    	function mediatags__edit_tags_fixes($parent_file)
    		if ( 'edit.php?post_type=attachment' == $parent_file )
    			// back-reference to Media menu, to fix proper side-menu focus
    			$parent_file = 'upload.php';	
    			// Give 'Show on screen' form other names, to avoid conflict with some WP filters (e.g. do not use - )
    			add_screen_option( 'per_page', array('label'  => 'Media-Tags', 'default' => 20,
    												 'option' => 'edit_mediatags_per_page',
    												 'value'  => 'edit_mediatags_per_page') );	
    			// Fix for 'Show on screen' form processing, to make applied rows work
    			// (code extracted from set_screen_options(), as I don't know yet how to hook this)
    			if ( isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options']) )
    				check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' );
    				if ( !$user = wp_get_current_user() ) return;
    				$option = $_POST['wp_screen_options']['option'];
    				$value  = $_POST['wp_screen_options']['value'];
    				// persist applied values in wp_usermeta table
    				update_user_meta($user->ID, $option, $value);
    				// redirect to set cookie
    				wp_redirect( remove_query_arg( array('pagenum', 'apage', 'paged'), wp_get_referer() ) );
    			return $parent_file;
    	add_action('parent_file', 'mediatags__edit_tags_fixes');
  2. Paul Menard
    Plugin Author

    Posted 3 years ago #

    Thanks for the code patch. Guess I'm confused on the actual issue this is supposed to correct.

  3. Paul Menard
    Plugin Author

    Posted 3 years ago #

    Never mind I see what this does. You are forcing the post_type for the edit tag URL. Cool. Thanks. Was not sure this was an issue.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic