Problem requiring/including plugin files with plugin_dir_path( __FILE__ )

When using plugin_dir_path() like you do: plugin_dir_path( __FILE__ ); It does return something like: /var/www//wordpress/wp-content/plugins/your-plugin/ So it adds a trailing slash, because as the documentation states: It is a wrapper for trailingslashit( dirname( $file ) );. So remove the slash before the file in your calls: require_once plugin_dir_path( __FILE__ ) . ‘file.php’;

Allowing for multiple template views on the Gallery Settings page when using the Visual Editor

It appears that the templates live in script form <script type=”text/html” id=”tmpl-my-custom-gallery-setting”> To render the above template would require wp.media.template(‘my-custom-gallery-setting’)(view) Since we’re replacing the template: logic then all we need to do is store a list of template IDs. if (!wp.media.gallery.templates) wp.media.gallery.templates = [‘gallery-settings’]; wp.media.gallery.templates.push(‘my-custom-gallery-setting’); Then loop through all available views wp.media.view.Settings.Gallery = wp.media.view.Settings.Gallery.extend({ template: … Read more

Managing two editable fields in gutenberg

Editable has been replaced with RichText in 2.2. Here’s a example of two RichText components being edit/saved together: const { __ } = wp.i18n; const { registerBlockType, RichText, } = wp.blocks; registerBlockType( ‘wtv/wtv’, { title: __( ‘wtv’, ‘wtv’ ), icon: ‘id’, category: ‘widgets’, keywords: [ __( ‘wtv’ ), __( ‘wtv’ ), __( ‘wtv’ ) ], … Read more

Adding pre-publish checks with Gutenberg

This got me started. Set up the block with create-guten-block Gitub Update block.js to something like: import ‘./style.scss’; import ‘./editor.scss’; var PluginPrePublishPanel = wp.editPost.PluginPrePublishPanel; var registerPlugin = wp.plugins.registerPlugin; function Component() { wp.data.dispatch(‘core/editor’).lockPostSaving() //do stuff //wp.data.dispatch(‘core/editor’).unlockPostSaving() return wp.element.createElement( PluginPrePublishPanel, { className: ‘my-plugin-publish-panel’, title: ‘Panel title’, initialOpen: true, }, ‘Panel content’ ); } registerPlugin( ‘my-plugin’, { render: … Read more

Is it possible to add an admin page using add_submenu_page() and pass a var in the query string?

Your menu slug (5th parameter) can’t be the same across multiple pages, and it obviously can’t have an & in it, but you can have all the pages you want call the same callback function (the last param). add_submenu_page(‘upload_manage’, “Programs”, “Programs”, ‘manage_options’, ‘manage-programs’, “manage_data”); add_submenu_page(‘upload_manage’, “Schedule”, “Schedule”, ‘manage_options’, ‘manage-schedule’, “manage_data”); Then in the manage_data function, … Read more

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