I'm trying to use the cmb_field_map extension by julykaz for cmb2 in a wordpress plugin to display a google map location.
https://packagist.org/packages/julykaz/cmb_field_map
Have successfully installed it into composer and action hook for cmb2_render_pw_map is registering in the page - but no field (or map) displayed.
cmb2 is installed and working correctly. By the documentation on the page, I should just have to add the appropriate type.
I've got:
$cmb_location->add_field( array(
'name' => 'Google Map Location',
'desc' => 'Drag the marker to set the exact location',
'id' => $prefix . 'map',
'type' => 'pw_map'
) );
In the admin edit page the 'name' field is display but nothing for the googlemap (or even a field).
Not sure what I'm missing here...
Look this -> https://github.com/mustardBees/cmb_field_map Propably you've probably forgotten Google Maps API key.
Related
I am using the code star framework full version. I have integrated the framework with the theme. How can I show the meta box option only for some specific pages ( like home page and about page )? Currently, the meta box options are showing all pages.
While creating metabox, you should pass "page_templates" value in array. For example, if you want to show metabox on homepage you should do:
$homePage = 'home-page';
CSF::createMetabox($homePage, array(
'title' => 'Homepage',
'post_type' => 'page',
'page_templates' => 'index.php', //filename goes here
'data_type' => 'serialize',
));
For more info: http://codestarframework.com/documentation/#/configurations?id=metabox-option-framework
I'm using Wordpress 4.9.5 with Woocommerce 3.3.5. I am using the WooCommerce REST API PHP Client Library to update products on the website when they are changed in a separate product management system. That library is using v2 of the REST API.
Using the following code I am successfully updating the basic product data (title, description, sku, price etc) but I can't get the categories to update from Uncategorized. The categories are also not set when using similar code to create a product if it doesn't already exist on the site.
$client = new WC_API_Client( $domain, $consumerKey, $consumerSecret, $options );
$client->products->update( $id, array(
'sku' => $product->sku,
'title' => $product->title,
'type' => $product->type,
'status' => $product->status,
'regular_price' => $product->regular_price,
'description' => $product->description,
'categories' => array(
array(
'id' => 343
),
array(
'id' => 347
)
)
));
As I say, the other fields update as expected. I have confirmed that categories with IDs 343 and 347 definitely exist so I assume I must have a problem with the syntax. As the other fields update the authentication is definitely working.
I have read the official Woocommerce API documentation and based my code on this tutorial. Based on both of those, I'm not sure what I have done wrong.
Thanks for any help or advice.
I resolved this in the end. It was on oversight on my part.
The client library I was using was connecting to what the Woocommerce documentation calls the 'Legacy v2' version rather than the 'v2' version of the API. Categories, image alt tags, meta data etc are not supported in the legacy versions.
I switched from the using library to connecting directly to the 'v2' version using https://sitename/wp-json/wc/v2/endpoint and all is now well.
I want to hide admin side my custom type Add New button. Review this screen shot -> https://s.nimbus.everhelper.me/share/1406976/p6f5u0nlvs5xff3sr85h
So any one know solutions then please update me.
Thanks.
you can use meta capability create_posts that is not documented but is used by WordPress to check before inserting the various 'Add New' buttons and links. In your custom post type declaration, add capabilities (not to be confused with cap) and then set it to false as below.
register_post_type( 'custom_post_type_name', array(
'capability_type' => 'post',
'capabilities' => array(
'create_posts' => false, // Removes support for the "Add New" function ( use 'do_not_allow' instead of false for multisite set ups )
),
'map_meta_cap' => true, // Set to `false`, if users are not allowed to edit/delete existing posts
));
Where custom_post_type_name you can put your custom post type name, which you are creating.
I created a custom field with the "advanced-custom-fields"-plugin. Now I want to get and output the custom field programmatically in my template file (backend, edit page), because my template is called via ajax if user want's to add a new region to the page.
Is there any function which returns the complete field? I only found functions which gave me values, but not the field as "form".
I found a solution. I duplicated the plugin folder into my theme root directory and put the following code into my functions.php:
function relationshipField() {
$newField = new acf_field_relationship();
$field = array(
'post_type' => array('post'),
'max' => '',
'taxonomy' => array('all'),
'filters' => array('search'),
'result_elements' => array('post_title', 'post_type'),
'return_format' => 'object'
);
return $newField->create_field($field);
}
In addition I append a custom input field (created in function.php) which stores only the post id's in database.
I am using the Meta Box plugin for Wordpress. I can successfully create fields in the cms for users to upload images. I would like to extend this in two ways:
First, I would like a delete confirmation when users remove an image from the image gallery
Here is the code:
$meta_boxes[] = array(
'id' => 'project_media',
'title' => 'Project Media',
'pages' => array( 'project' ),
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array(
'name' => 'Media Gallery',
'desc' => 'Images should be sized to 983px x 661px',
'id' => $prefix . 'project_media_gallery',
'type' => 'image'
)
);
This creates upload functionality in the custom post type where users can add images to a slideshow. The problem is if the user accidentally clicks the delete button, there is no confirmation to make sure it is deleted. Can I somehow extend the plugin through functions and call an alert when this button is clicked? Something that does not involve editing the WP core?
Second, the base functionality requires the user to upload an image from their local machine. Is there a way to tap into the Media Library for this?
No idea how to even start tackling this one.
To answer the first question
First, I would like a delete confirmation when users remove an image from the image gallery
You can do that by calling a custom script file from the functions.php.
function alert_delete() {
if(is_admin()){
wp_register_script( 'alert_delete', get_bloginfo('template_url'). '/js/alert_delete.js', array('jquery'));
wp_enqueue_script('alert_delete');
}
}
and create a file named alert_delete.js in the js directory of your theme.
alert_delete.js:
// admin delete check
jQuery(document).ready(function(){
jQuery(".rwmb-delete-file").click(function() {
if (!confirm("Are you sure? This process cannot be undone.")){
return false;
}
});
});
In response to the second question...
Second, the base functionality requires the user to upload an image
from their local machine. Is there a way to tap into the Media Library
for this?
Get the latest version of the Meta Box Plugin first.
then change
'type' => 'image'
to
'type' => 'image_advanced'
which will allow you to upload from the existing Media Gallery or a new file from your computer.