Giulio
Forum Replies Created
-
Forum: Developing with WordPress
In reply to: Problem with Widget and Code Editor APII 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 filecustom-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 usingwp_enqueue_script
does not seem to work. Then I worked onInitializeEditor
andInit
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.Forum: Developing with WordPress
In reply to: Settings API for user profile page?OK Thank you very much
Forum: Hacks
In reply to: Allow user to edit his posts only onceExcellent!
Thank you very much!Forum: Hacks
In reply to: What is the best data structure for meta boxes?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 submenuOK thank you.
Forum: Hacks
In reply to: Attach CPT to submenuHi,
I’m callingsetup_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’sforeach (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 capabilitiesThank you!
Forum: Hacks
In reply to: Apropos capabilitiesThank 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 TypeOK, thank you very much!