wp_enqueue_script() with unknown path and maybe symlink

I think this can help you. I did something similar in one of the plugins I’m developing. static function enqueue_admin_scripts( string $hook_suffix ): void { if ( self::get_page_hook_suffix() !== $hook_suffix ) { return; } $utils_path = self::get_utils_script_path(); if ( ! empty( $utils_path ) ) { wp_enqueue_script( ‘my-plugin-utils’, $utils_path ); } } static function get_utils_script_path(): string … Read more

Where can I store data in WordPress?

In my experience, update_option() and update_post_meta() are what I need over 90% of the time. Use update_option() if you want to save data related to the site overall, and use update_post_meta() if you want to save data related to a specific post. The other ~10% of the time I might need something more esoteric, like … Read more

Custom post type template not loading from plugin

I think your first method isn’t working because it’s a theme method, not a plugin method. I could be entirely incorrect but I think the method of using single-custom_post_type.php only works for themes. (Again, I 100% could be wrong.) However, this is what I use and it always works: function wpse_post_type_templates( $template ) { if( … Read more

the function do_settings_section($page) generate error “Allowed memory size of … bytes exhausted”

You seem to be creating a recursive loop. In stm_addmenu_auto_delete_event(), you register an admin page via add_menu_page() that has a callback of auto_delete_settings_callback: function stm_addmenu_auto_delete_event() { add_menu_page( ‘Automatic deletion’, ‘Automatic <br/> deletion’, ‘manage_options’, ‘manage-auto-delete-page’, ‘auto_delete_settings_callback’, In new_settings_auto_delete you register a settings field with a callback of auto_delete_settings_callback: function new_settings_auto_delete() { // … add_settings_field( ‘default_auto_delete_field’, ‘By … Read more

Translations not making it into Block UI but work in the rest of the plugin

It seems like you do not have any JavaScript localization files to use with wp_set_script_translations(). If we consult the Gutenberg/JavaScript documentation for internationalization: The translation files must be in the JED 1.x JSON format. […] <?php function myguten_set_script_translations() { wp_set_script_translations( ‘myguten-script’, ‘myguten’, plugin_dir_path( __FILE__ ) . ‘languages’ ); } add_action( ‘init’, ‘myguten_set_script_translations’ ); WordPress will … Read more

Does it make sense to sanitize the output of an SVG file?

It’s not completely pointless, but probably smart to sanitize, because of the following situations: What’s the certainty that the SVGs only come from you directly? Can you guarantee that the SVGs won’t be intercepted during upload? Redundancies for keeping your site secure are generally recommended. I don’t know that wp_kses() is the best for sanitizing … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)