Only displaying zip files with wp media
The zip files are in a subtype called application so you should try using: type: ‘application/zip’ A list of default allowed mime types is available from wp_get_mime_types.
The zip files are in a subtype called application so you should try using: type: ‘application/zip’ A list of default allowed mime types is available from wp_get_mime_types.
Given a setting with an ID of “foo” you can obtain the value via: var value = wp.customize( ‘foo’ ).get() To ensure that the setting is registered before you attempt to get its value, you can use this deferred pattern: wp.customize( ‘foo’, function( setting ) { var value = setting.get(); // … }); This should … Read more
The WordPress way to do this is the wp_localize_script() function. When you enqueue a script, also add a call to wp_localize_script(): wp_register_script( ‘my-script’, ‘path/to/script.js’ ); wp_localize_script( ‘my-script’, ‘myScript’, array( ‘msg_must_match’ => __( ‘Message must match’, ‘my-plugin-domain’ ), ) ); This creates a global JavaScript object called myScript that will contain the keys and values passed … Read more
If you want to output a single line of javascript, you might not need to put it in a js file and go through enqueuing it and stuff. Simply output it by using the wp_footer() action hook: add_action(‘wp_footer’,’print_my_script’); function print_my_script(){ echo ‘<script> // Your script here </script>’; } However, this is good just for small … Read more
plugin_dir_url( __FILE__ ) returns plugin URL with a trailing slash (/). So you have to remove the extra trailing slash. wp_enqueue_script( ‘awesome_form_validation’, plugin_dir_url( __FILE__ ). ‘js/form_validation.js’, array(), ‘1.0.0’, true );
I think you have to pass in menu_selected edit: withAPIData( ( props ) => { return { menu_selected: `/menus/v1/menus/${ props.attributes.menu }` // custom endpoint }; } ) ( ( { menu_selected } ) => { I was able to do a very similar thing like so: edit: withAPIData( () => { return { posts: ‘/wp/v2/images?per_page=4&_embed’ … Read more
You can try this add-on to make conditional fields. https://nl.wordpress.org/plugins/cf7-conditional-fields/
In this tutorial, the post var status=”draft”; (see code). So I am just worried that won’t anyone able to hack that status? It depends who it is. A logged out user cannot create any posts at all. A subscriber cannot either. A contributor could create the post, but not publish it. An author or editor … Read more
You have to look through your theme to see where the js file is enqueued. Usually there is a functions.php file in the theme which will have all the special functions and actions. Sometimes the developer will put all the enqueued scripts into the theme template (i.e. single.php) before get_header() is called. In any event, … Read more
You’re right you should be using an id. I would use a counter in conjunction with get_the_ID(); $arr_posts = new WP_Query( $args ); if ( $arr_posts->have_posts() ) : $index = 0; while ( $arr_posts->have_posts() ) : $arr_posts->the_post(); echo $index . ‘_’ . get_the_ID(); endwhile; endif; This will give you a unique id which you can … Read more