how to use thickbox in admin?

Below, an example of what’s needed to use ThickBox. <?php wp_enqueue_style(‘thickbox’); wp_enqueue_script(‘thickbox’); ?> <a href=”#” id=”taxonomy_banner_image” class=”taxonomy_banner_image”> Click Here </a> <script type=”text/javascript”> jQuery(document).ready(function() { jQuery(“#taxonomy_banner_image”).click(function() { tb_show(“”, “filename?TB_iframe=true”); return false; }); }); </script> tb_show parameters: title of the box. url of file and with parameter iframe=true I think this will give you an idea how … Read more

Changing upload directory for plugin uploads only

There must be something identifiable about your form data, such as your input names. Check for one or more of those and process accordingly. function custom_upload_dir($args) { if (isset($_POST[‘something’])) { $args[‘path’] = $args[‘basedir’] . “/mypath” . $args[‘subdir’]; $args[‘url’] = $args[‘baseurl’] . “/mypath” . $args[‘subdir’]; } return $args; } After some investigation, the only things I … Read more

How to make repeated component/block in Gutenberg

I think the best way to approach this is by creating 2 blocks with a parent -> child relationship. The child block would be a nested block only available within its parent block. Note the parent defined below. registerBlockType( ‘prefix/childblock’, { title: __( ‘Inner Child Block’ ), parent: [‘prefix/parentblock’], attributes:{ …//the rest of your block … Read more

How to edit the properties of a page programmatically?

If you look at the documentation, you can insert title, content, slug, etc. using wp_insert_post then use update_post_meta to assign the template to that post. You can write like this $post_arr = array( ‘post_title’=>’My title goes here’, ‘post_content’=>’This is my long content.’, ‘post_excerpt’ => ‘My Excerpt’, ‘post_status’ => ‘publish’, ); $new_post_id = wp_insert_post($post_arr); Then set … Read more

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

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