Forum Replies Created

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter Giulio

    (@ferocious)

    I don’t like answering my own question, but I feel this is the one of the possible solutions so far, but not the best:
    I used the file custom-html-widgets.js as a model for my own plugin, renaming the main method to avoid conflicts to runtime. Each plugin needs this file in order to use Codemirror into the Widgets panel and connecting it directly by using wp_enqueue_script does not seem to work. Then I worked on InitializeEditor and Init in order to find the selector for the textarea of my widget. At last I did register this new script with wp_register_script in the Widget extended class.

    Thread Starter Giulio

    (@ferocious)

    OK Thank you very much

    Thread Starter Giulio

    (@ferocious)

    Excellent!
    Thank you very much!

    Thread Starter Giulio

    (@ferocious)

    Hello Bcworks, thank you for your reply.
    The CPT plays a central role in my plugin. I’m trying to develop a D&D character builder. Maybe I could use the Metadata API for storing the fields into WordPress after they have been serialized on plugin activation. Does it make sense? But the job gets too complicated.
    Thank you again.

    Forum: Hacks
    In reply to: Attach CPT to submenu
    Thread Starter Giulio

    (@ferocious)

    OK thank you.

    Forum: Hacks
    In reply to: Attach CPT to submenu
    Thread Starter Giulio

    (@ferocious)

    Hi,
    I’m calling setup_menu() with the construct of a class using the init hook:

    index.php:
    add_action( 'init' 'admin_actions');
    function admin_actions() {
     new Mf_Menu();
     ...
    }
    
    class.mf-menu.php:
    class Mf_Menu() {
      public function __construct() {
        add_action( 'admin_menu', array ( $this, 'setup_menu') );
      }
      ...
    }

    The menu is working fine when I set show_in_menu to true in register_post_type(), but when its value is false or string post-new.php returns the error message and I can only edit/read/delete CPTs.
    I have noticed that WordPress prints the message error when !user_can_access_admin_page() returns false in wp-admin/menu.php. So I looked for the condition that returns false in wp-admin/plugin.php it’s

    foreach (array_keys( $_wp_submenu_nopriv ) as $key )
    if ( isset( $_wp_submenu_nopriv[$key][$pagenow] ) )
        return false;

    when I set show_in_menu to false or string, the global variable $parent is set to an empty string. When I set show_in_menu to true then $parent is set to ‘edit.php?post_type=mf_product’ and everything works correctly but a top-level menu for the CPT is not what I want.

    Forum: Hacks
    In reply to: Apropos capabilities
    Thread Starter Giulio

    (@ferocious)

    Thank you!

    Forum: Hacks
    In reply to: Apropos capabilities
    Thread Starter Giulio

    (@ferocious)

    Thank you very much bcworkz!
    Could you tell me if the following code is safe for production?

    add_action( 'load-edit.php', 'm_show_posts' );
    
    function m_show_posts() {
    add_action( 'pre_get_posts', function( $query ) {
    		$user_id = get_current_user_id();
    		if ( is_post_type_archive( 'm_product' ) && $query->is_main_query() ) {
    			$query->set( 'author', $user_id );
    		}
    } );

    How could I stop someone from requesting an individual post of someone else?

    Forum: Hacks
    In reply to: Problem with Costum Post Type
    Thread Starter Giulio

    (@ferocious)

    OK, thank you very much!

Viewing 9 replies - 1 through 9 (of 9 total)