Related
In functions.php I am trying to use this, but it is not working:
function rt_woocommerce_admin_shipping_fields( $fields ) {
$fields['first_name']['value'] = $_GET['f'];
$fields['last_name']['value'] = $_GET['l'];
$fields['address_1']['value'] = $_GET['a'];
$fields['address_2']['value'] = $_GET['b'];
// etc
// etc
return $fields;
}
add_filter( 'woocommerce_admin_shipping_fields', 'rt_woocommerce_admin_shipping_fields' );
woocommerce_admin_billing_fields() works but the shipping function does not. Any advice? I need to update the fields with $_GET variables on page load. This works perfectly for the billing fields.
The array has label and show indexes for each item in shipping fields. There is no value index by default. See the woocommerce_admin_shipping_fields filter below.
self::$shipping_fields = apply_filters(
'woocommerce_admin_shipping_fields',
array(
'first_name' => array(
'label' => __( 'First name', 'woocommerce' ),
'show' => false,
),
'last_name' => array(
'label' => __( 'Last name', 'woocommerce' ),
'show' => false,
),
'company' => array(
'label' => __( 'Company', 'woocommerce' ),
'show' => false,
),
'address_1' => array(
'label' => __( 'Address line 1', 'woocommerce' ),
'show' => false,
),
'address_2' => array(
'label' => __( 'Address line 2', 'woocommerce' ),
'show' => false,
),
'city' => array(
'label' => __( 'City', 'woocommerce' ),
'show' => false,
),
'postcode' => array(
'label' => __( 'Postcode / ZIP', 'woocommerce' ),
'show' => false,
),
'country' => array(
'label' => __( 'Country / Region', 'woocommerce' ),
'show' => false,
'type' => 'select',
'class' => 'js_field-country select short',
'options' => array( '' => __( 'Select a country / region…', 'woocommerce' ) ) + WC()->countries->get_shipping_countries(),
),
'state' => array(
'label' => __( 'State / County', 'woocommerce' ),
'class' => 'js_field-state select short',
'show' => false,
),
'phone' => array(
'label' => __( 'Phone', 'woocommerce' ),
),
)
);
I need to create a child plugin for a popular plugin
There are a few functions in the main plugin that I need to edit (by the Child plugin) How do I do this?
Note: There is a function in the main plugin, I just need to add code to it with the plugin child
Desired function:
function dokan_get_social_profile_fields() {
$fields = array(
'fb' => array(
'icon' => 'facebook-square',
'title' => __( 'Facebook', 'dokan-lite' ),
),
'gplus' => array(
'icon' => 'google',
'title' => __( 'Google', 'dokan-lite' ),
),
'twitter' => array(
'icon' => 'twitter-square',
'title' => __( 'Twitter', 'dokan-lite' ),
),
'pinterest' => array(
'icon' => 'pinterest-square',
'title' => __( 'Pinterest', 'dokan-lite' ),
),
'linkedin' => array(
'icon' => 'linkedin-square',
'title' => __( 'LinkedIn', 'dokan-lite' ),
),
'youtube' => array(
'icon' => 'youtube-square',
'title' => __( 'Youtube', 'dokan-lite' ),
),
'instagram' => array(
'icon' => 'instagram',
'title' => __( 'Instagram', 'dokan-lite' ),
),
'flickr' => array(
'icon' => 'flickr',
'title' => __( 'Flickr', 'dokan-lite' ),
),
);
return apply_filters( 'dokan_profile_social_fields', $fields );
}
The amount I need to add to it with the Child Plugin:
,
'telgram' => array(
'icon' => 'telgram',
'title' => __( 'Telgram', 'dokan-lite' ),
),
'discord' => array(
'icon' => 'discord',
'title' => __( 'Discord', 'dokan-lite' ),
),
I am trying to use Redux inside the wordpress theme and not as a plugin. In functions.php I included both redux-framework.php and sample-config.php .
Now I need to create a repeater field.
From Redux doc, I got the following code to use in order to create a repeater field:
$this->sections[] = array(
'title' => __('Repeater Field', 'redux-framework-demo' ),
'icon' => 'el-icon-thumbs-up',
'fields' => array(
array(
'id' => 'repeater-field-id',
'type' => 'repeater',
'title' => __( 'Title', 'redux-framework-demo' ),
'subtitle' => __( '', 'redux-framework-demo' ),
'desc' => __( '', 'redux-framework-demo' ),
//'group_values' => true, // Group all fields below within the repeater ID
//'item_name' => '', // Add a repeater block name to the Add and Delete buttons
//'bind_title' => '', // Bind the repeater block title to this field ID
//'static' => 2, // Set the number of repeater blocks to be output
//'limit' => 2, // Limit the number of repeater blocks a user can create
//'sortable' => false, // Allow the users to sort the repeater blocks or not
'fields' => array(
array(
'id' => 'title_field',
'type' => 'text',
'placeholder' => __( 'Title', 'redux-framework-demo' ),
),
array(
'id' => 'text_field',
'type' => 'text',
'placeholder' => __( 'Text Field', 'redux-framework-demo' ),
),
array(
'id' => 'select_field',
'type' => 'select',
'title' => __( 'Select Field', 'redux-framework-demo' ),
'options' => array(
'1' => __( 'Option 1', 'redux-framework-demo' ),
'2' => __( 'Option 2', 'redux-framework-demo' ),
'3' => __( 'Option 3', 'redux-framework-demo' ),
),
'placeholder' => __( 'Listing Field', 'redux-framework-demo' ),
),
)
)
)
);
but if I place the code inside functions.php, what will the $this variable refer to? It'll produce errors. So how to use the snippet so that I can retrieve the values from template files as well?
You have to tried an old version system to create a section. You can try the new version system, I'm not sure if this works or not, but you can try this way:
Redux::setSection($opt_name, array(
'title' => __('Ads Sections', 'cbnews'),
'id' => 'ads-sections',
'desc' => __('You can manage your ads', 'cbnews'),
'icon' => 'dashicons dashicons-dashboard',
'fields' => array(
array(
'id' => 'repeater-field-id',
'type' => 'repeater',
'title' => __( 'Title', 'redux-framework-demo' ),
'subtitle' => __( '', 'redux-framework-demo' ),
'desc' => __( '', 'redux-framework-demo' ),
//'group_values' => true, // Group all fields below within the repeater ID
//'item_name' => '', // Add a repeater block name to the Add and Delete buttons
//'bind_title' => '', // Bind the repeater block title to this field ID
//'static' => 2, // Set the number of repeater blocks to be output
//'limit' => 2, // Limit the number of repeater blocks a user can create
//'sortable' => false, // Allow the users to sort the repeater blocks or not
'fields' => array(
array(
'id' => 'title_field',
'type' => 'text',
'placeholder' => __( 'Title', 'redux-framework-demo' ),
),
array(
'id' => 'text_field',
'type' => 'text',
'placeholder' => __( 'Text Field', 'redux-framework-demo' ),
),
array(
'id' => 'select_field',
'type' => 'select',
'title' => __( 'Select Field', 'redux-framework-demo' ),
'options' => array(
'1' => __( 'Option 1', 'redux-framework-demo' ),
'2' => __( 'Option 2', 'redux-framework-demo' ),
'3' => __( 'Option 3', 'redux-framework-demo' ),
),
'placeholder' => __( 'Listing Field', 'redux-framework-demo' ),
),
)
)
)
));
I just upgraded our server and it has the latest version of php. When users try to log in to our website we get the following error:
The staging.ilovenz.me page isn’t working
staging.ilovenz.me didn’t send any data.
ERR_EMPTY_RESPONSE
I have checked the log files and we have the following error:
[28-Feb-2017 22:23:33 UTC] PHP Warning: in_array() expects parameter 2 to be array, boolean given in /mnt/stor14-wc1-dfw3/staging.ilovenz.me/web/content/wp-content/themes/kleo/lib/options.php on line 2416
After looking at the file on line 2416 I can see the following function, which I have no Idea what to do with it... Some help would be amazing!
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
$sections[] = array(
'icon' => 'el-icon-shopping-cart',
'icon_class' => 'icon-large',
'title' => __( 'Woocommerce', 'kleo_framework' ),
'customizer' => false,
'desc' => '',
'fields' => array(
array(
'id' => 'woo_sidebar',
'type' => 'select',
'compiler' => true,
'title' => __( 'Woocommerce Pages Layout', 'kleo_framework' ),
'subtitle' => __( 'Select the layout to use in Woocommerce pages.', 'kleo_framework' ),
'options' => array(
'default' => 'Default site layout',
'no' => 'Full width',
'left' => 'Left Sidebar',
'right' => 'Right Sidebar',
'3lr' => '3 Column, Left and Right Sidebars',
'3ll' => '3 Column, 2 Left sidebars',
'3rr' => '3 Column, 2 Right sidebars'
),
'default' => 'default'
),
array(
'id' => 'woo_cat_sidebar',
'type' => 'select',
'compiler' => true,
'title' => __( 'Woocommerce Category Layout', 'kleo_framework' ),
'subtitle' => __( 'Select the layout to use in Woocommerce product listing pages.', 'kleo_framework' ),
'options' => array(
'default' => 'Default as set above',
'no' => 'Full width',
'left' => 'Left Sidebar',
'right' => 'Right Sidebar',
'3lr' => '3 Column, Left and Right Sidebars',
'3ll' => '3 Column, 2 Left sidebars',
'3rr' => '3 Column, 2 Right sidebars'
),
'default' => 'default'
),
array(
'id' => 'woo_single_sidebar',
'type' => 'select',
'compiler' => true,
'title' => __( 'Woocommerce Single Product Layout', 'kleo_framework' ),
'subtitle' => __( 'Select the layout to use in Woocommerce single product pages.', 'kleo_framework' ),
'options' => array(
'default' => 'Default as set above',
'no' => 'Full width',
'left' => 'Left Sidebar',
'right' => 'Right Sidebar',
'3lr' => '3 Column, Left and Right Sidebars',
'3ll' => '3 Column, 2 Left sidebars',
'3rr' => '3 Column, 2 Right sidebars'
),
'default' => 'default'
),
array(
'id' => 'woo_cart_location',
'type' => 'button_set',
'title' => __( 'Menu cart location', 'kleo_framework' ),
'subtitle' => __( 'Shopping Cart in header menu location', 'kleo_framework' ),
'options' => array(
'off' => 'Disabled',
'primary' => 'Primary menu',
'secondary' => 'Secondary menu',
'top' => 'Top menu'
),
'default' => 'primary'
),
array(
'id' => 'woo_mobile_cart',
'type' => 'switch',
'title' => __( 'Mobile menu Cart Icon', 'kleo_framework' ),
'subtitle' => __( 'This will show on mobile menu a shop icon with the number of cart items', 'kleo_framework' ),
'default' => '1' // 1 = checked | 0 = unchecked
),
array(
'id' => 'woo_image_effect',
'type' => 'button_set',
'title' => __( 'Product image effect', 'kleo_framework' ),
'subtitle' => __( 'The effect on products listing when hovering an image.', 'kleo_framework' ),
'options' => array(
'default' => 'Bottom-Top',
'fade' => 'Fade',
'alt' => 'Left-Right',
'single' => 'No effect'
),
'default' => 'default'
),
array(
'id' => 'woo_product_animate',
'type' => 'switch',
'title' => __( 'Enable product listing Appear Animation', 'kleo_framework' ),
'subtitle' => __( 'On product listing the products will have a appear animation.', 'kleo_framework' ),
'default' => '1' // 1 = checked | 0 = unchecked
),
array(
'id' => 'woo_percentage_badge',
'type' => 'switch',
'title' => __( 'Show percentage badge on products list', 'kleo_framework' ),
'subtitle' => __( 'This will replace the "Sale" badge with "SAVE UP TO xx%"', 'kleo_framework' ),
'default' => '0' // 1 = checked | 0 = unchecked
),
array(
'id' => 'woo_percent_color',
'type' => 'color',
'required' => array( 'woo_percentage_badge', '=', '1' ),
'title' => __( 'Custom Badge color', 'kleo_framework' ),
'subtitle' => '',
'default' => '#ffffff' // 1 = checked | 0 = unchecked
),
array(
'id' => 'woo_percent_bg',
'type' => 'color',
'required' => array( 'woo_percentage_badge', '=', '1' ),
'title' => __( 'Custom Badge Background', 'kleo_framework' ),
'subtitle' => '',
'default' => '#000000' // 1 = checked | 0 = unchecked
),
array(
'id' => 'woo_free_badge',
'type' => 'switch',
'title' => __( 'Show free badge on products list', 'kleo_framework' ),
'default' => '1' // 1 = checked | 0 = unchecked
),
array(
'id' => 'woo_new_badge',
'type' => 'switch',
'title' => __( 'Show NEW badge for new products added', 'kleo_framework' ),
'subtitle' => '',
'default' => '1' // 1 = checked | 0 = unchecked
),
array(
'id' => 'woo_show_excerpt_single',
'type' => 'switch',
'title' => __( 'Show excerpt on product page', 'kleo_framework' ),
'subtitle' => '',
'default' => '0' // 1 = checked | 0 = unchecked
),
array(
'id' => 'woo_product_navigation',
'type' => 'switch',
'title' => __( 'Enable product navigation', 'kleo_framework' ),
'subtitle' => 'Display previous and next product navigation',
'default' => '1' // 1 = checked | 0 = unchecked
),
array(
'id' => 'woo_buddypress_menus',
'type' => 'switch',
'title' => __( 'Manage account in Buddypress', 'kleo_framework' ),
'subtitle' => __( 'Integrates "My Account" into Buddypress profile tabs', 'kleo_framework' ),
'default' => '1' // 1 = checked | 0 = unchecked
),
array(
'id' => 'woo_new_days',
'type' => 'text',
'required' => array( 'woo_new_badge', '=', '1' ),
'title' => __( 'Number of days to treat a product as new', 'kleo_framework' ),
'subtitle' => __( 'For how many days to show the NEW badge once a product is added to the shop.', 'kleo_framework' ),
'default' => '7' // 1 = checked | 0 = unchecked
),
array(
'id' => 'woo_catalog',
'type' => 'button_set',
'title' => __( 'Catalog mode', 'kleo_framework' ),
'subtitle' => __( 'If you enable catalog mode will disable Add To Cart buttons, Checkout and Shopping cart.', 'kleo_framework' ),
'options' => array(
'0' => 'No',
'1' => 'Yes'
),
'default' => '0'
),
array(
'id' => 'woo_disable_prices',
'type' => 'button_set',
'title' => __( 'Disable prices', 'kleo_framework' ),
'subtitle' => __( 'Disable prices on category pages and product page', 'kleo_framework' ),
'options' => array(
'0' => 'No',
'1' => 'Yes'
),
'required' => array( 'woo_catalog', '=', '1' ),
'default' => '0'
),
array(
'id' => 'woo_shop_columns',
'type' => 'select',
'title' => __( 'Shop Products Columns', 'kleo_framework' ),
'subtitle' => __( 'Select the number of columns to use for products display.', 'kleo_framework' ),
'options' => array(
'3' => '3',
'4' => '4',
'5' => '5',
'6' => '6'
),
'default' => '3'
),
array(
'id' => 'woo_shop_products',
'type' => 'text',
'title' => __( 'Shop Products per page', 'kleo_framework' ),
'subtitle' => __( 'How many products to show per page', 'kleo_framework' ),
'default' => '15' // 1 = checked | 0 = unchecked
),
array(
'id' => 'woo_related_columns',
'type' => 'select',
'title' => __( 'Related Products number', 'kleo_framework' ),
'subtitle' => __( 'Select the number of related products to show on product page.', 'kleo_framework' ),
'options' => array(
'3' => '3',
'4' => '4',
'5' => '5',
'6' => '6'
),
'default' => '3'
),
array(
'id' => 'woo_upsell_columns',
'type' => 'select',
'title' => __( 'Upsell Products number', 'kleo_framework' ),
'subtitle' => __( 'Select the number of upsell products to show on product page.', 'kleo_framework' ),
'options' => array(
'3' => '3',
'4' => '4',
'5' => '5',
'6' => '6'
),
'default' => '3'
),
array(
'id' => 'woo_cross_columns',
'type' => 'select',
'title' => __( 'Cross-sell Products number', 'kleo_framework' ),
'subtitle' => __( 'Select the number of Cross-sell products to show on cart page.', 'kleo_framework' ),
'options' => array(
'3' => '3',
'4' => '4',
'5' => '5',
'6' => '6'
),
'default' => '3'
)
)
);
}
I need a Webinar in my wordpress site. So I'm registering an meta box for my custom post type. I can see my custom post in the wordpress admin panel, but inside the custom post meta box is missing. What is wrong here!
// Meta boxes
add_filter( 'rwmb_meta_boxes', 'navbig_webinars_register_meta_boxes' );
//Register meta boxes
function navbig_webinars_register_meta_boxes( $meta_boxes )
{
$prefix = 'navbig_webinars_';
$meta_boxes[] = array(
'id' => 'standard',
'title' => __( 'Webinar Data', 'rwmb' ),
'pages' => array( 'webinar' ),
'context' => 'normal',
'priority' => 'high',
'autosave' => true,
'fields' => array(
array(
'name' => __( 'Date of Webinar', 'rwmb' ),
'id' => "webinar_date",
'type' => 'date',
// jQuery date picker options. See here http://api.jqueryui.com/datepicker
'js_options' => array(
'dateFormat' => __( 'dd-MM-yy', 'rwmb' ),
'changeMonth' => true,
'changeYear' => true,
'showButtonPanel' => true,
),
),
array(
'name' => __( 'Location', 'rwmb' ),
'id' => "webinar-location",
'type' => 'text',
'std' => __( 'Default text value', 'rwmb' ),
),
array(
'name' => __( 'Time Of Webinar', 'rwmb' ),
'id' => 'webinar_time',
'type' => 'time',
'js_options' => array(
'stepMinute' => 5,
'showSecond' => true,
'stepSecond' => 10,
),
),
array(
'name' => __( 'Select Time Zone', 'rwmb' ),
'id' => "select-timezone",
'type' => 'select_advanced',
'options' => array(
'value1' => __( 'PST', 'rwmb' ),
'value2' => __( 'EST', 'rwmb' ),
),
'multiple' => false,
'placeholder' => __( 'Select an Coures Type', 'rwmb' ),
),
// URL
array(
'name' => __( 'Webinar URL', 'rwmb' ),
'id' => "webinar_url",
'type' => 'url',
'std' => 'http://google.com',
),
array(
'name' => __( 'Webinar Banner', 'rwmb' ),
'id' => "webinar_banner",
'type' => 'thickbox_image',
),
),
);
return $meta_boxes;
}
You can find more detail about meta boxes here.
Here is sample add_meta_box code:-
add_meta_box(
'some_meta_box_name'
,__( 'Some Meta Box Headline', 'plugin_textdomain' )
,'render_meta_box_content' //this is callback function.
,'post_type'
,'advanced'
,'high'
);