Related
I am using the Reveal theme to create a listing website and I recently discovered the Advanced Custom Forms (Custom fields).
On my homepage, there is an Elementor block of this Reveal plugin that allows me to display custom posts.
I'd like to adapt an Elementor widget to filter out listings with a value of 1 in the "FreeListing" custom field (basically exclude them).
I saw that this link offered the solution : How to Filter Elementor Posts By a Custom Field's value in wordpress To make a long story short, everyone adds this to add_action, according to my research, but I have never seen this in my home.
But in my code I don't see how to introduce this. Do you know if I'm editing in the wrong place, or if I can do it here?
<?php
namespace Reveal\Core\Elementor\Widgets;
use Elementor\Controls_Manager;
use Elementor\Widget_Base;
class Popular_Listings_TwoNoFreeListing extends Widget_Base {
public function get_name() {
return 'reveal_popular_listings_2';
}
public function get_title() {
return esc_html__( 'Popular Listings No Free', 'reveal-core' );
}
public function get_icon() {
return 'eicon-banner';
}
public function get_categories() {
return array( 'reveal-core' );
}
protected function register_controls() {
$this->start_controls_section(
'general',
array(
'label' => esc_html__( 'General', 'reveal-core' ),
)
);
$this->add_control(
'title',
array(
'label' => esc_html__( 'Title', 'reveal-core' ),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'default' => __( 'Most Popular Grid', 'reveal-core' ),
)
);
$this->add_control(
'showposts',
array(
'label' => esc_html__( 'Number Of Listing', 'reveal-core' ),
'type' => Controls_Manager::TEXT,
'default' => 6,
)
);
$this->add_control(
'orderby',
array(
'label' => esc_html__( 'Order By', 'reveal-core' ),
'type' => Controls_Manager::SELECT,
'options' => array(
'date' => esc_html__( 'Date', 'reveal-core' ),
'id' => esc_html__( 'ID', 'reveal-core' ),
'title' => esc_html__( 'Title', 'reveal-core' ),
'name' => esc_html__( 'Name', 'reveal-core' ),
'modified' => esc_html__( 'Modified', 'reveal-core' ),
'rand' => esc_html__( 'Random', 'reveal-core' ),
),
'default' => 'date',
)
);
$this->add_control(
'order',
array(
'label' => esc_html__( 'Sort Order', 'reveal-core' ),
'type' => Controls_Manager::SELECT,
'options' => array(
'desc' => esc_html__( 'Descending', 'reveal-core' ),
'asc' => esc_html__( 'Ascending', 'reveal-core' ),
),
'default' => 'desc',
)
);
$this->add_control(
'extra_class',
array(
'label' => esc_html__( 'Extra Class', 'reveal-core' ),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'default' => 'popular-listing',
)
);
$this->end_controls_section();
$this->start_controls_section(
'style_section',
array(
'label' => __('Color Option', 'reveal-core'),
'tab' => \Elementor\Controls_Manager::TAB_STYLE,
)
);
$this->start_controls_tabs( 'tabs_button_style' );
$this->start_controls_tab(
'tab_button_normal',
array(
'label' => __( 'Normal', 'elementor' ),
)
);
$this->add_control(
'icon_color',
array(
'label' => __('Icon Color', 'reveal-core'),
'separator' => 'before',
'type' => \Elementor\Controls_Manager::COLOR,
'selectors' => array(
'{{WRAPPER}} .cat-icon i' => 'background: {{VALUE}} !important',
),
)
);
$this->add_control(
'icon_color_two',
array(
'label' => __('Icon Color Two', 'reveal-core'),
'separator' => 'before',
'type' => \Elementor\Controls_Manager::COLOR,
'selectors' => array(
'{{WRAPPER}} .bg-d' => 'background: {{VALUE}} !important',
),
)
);
$this->add_control(
'rating_color',
array(
'label' => __('Rating Color', 'reveal-core'),
'separator' => 'before',
'type' => \Elementor\Controls_Manager::COLOR,
'selectors' => array(
'{{WRAPPER}} .property_item .list-rate' => 'background: {{VALUE}} !important',
),
)
);
$this->add_control(
'checkek',
array(
'label' => __('Checked Icon Color', 'reveal-core'),
'separator' => 'before',
'type' => \Elementor\Controls_Manager::COLOR,
'selectors' => array(
'{{WRAPPER}} span.veryfied-author:before' => 'background: {{VALUE}} !important',
),
)
);
$this->add_control(
'status_color',
array(
'label' => __('Status Color', 'reveal-core'),
'separator' => 'before',
'type' => \Elementor\Controls_Manager::COLOR,
'selectors' => array(
'{{WRAPPER}} .place-status.closed' => 'color: {{VALUE}} !important',
),
)
);
$this->end_controls_tab();
$this->start_controls_tab(
'tab_button_hover',
array(
'label' => __( 'Hover', 'elementor' ),
)
);
$this->add_control(
'title_color',
array(
'label' => __('Title Hover Color', 'reveal-core'),
'separator' => 'before',
'type' => \Elementor\Controls_Manager::COLOR,
'selectors' => array(
'{{WRAPPER}} .proerty_text .captlize a:hover' => 'color: {{VALUE}} !important',
'{{WRAPPER}} .listing-cat a:hover' => 'color: {{VALUE}} !important',
),
)
);
$this->end_controls_tab();
$this->end_controls_tabs();
$this->end_controls_section();
}
protected function render() {
$settings = $this->get_settings_for_display();
$extra_class = $settings['extra_class'];
$title = $settings['title'];
$showposts = $settings['showposts'];
$orderby = $settings['orderby'];
$order = $settings['order'];
$args = array(
'post_type' => 'rlisting',
'post_status' => 'publish',
'showposts' => $showposts,
'orderby' => $orderby,
'order' => $order,
);
$listing_query = new \WP_Query( $args );
?>
<!-- ================ List Grid Style ======================= -->
<section class="<?php echo $extra_class; ?>">
<div class="container">
<div class="row">
<!-- Single List -->
<?php
while ($listing_query->have_posts()) {
$listing_query->the_post();
?>
<div class="col-lg-4 col-md-6 col-sm-12">
<?php
echo do_shortcode('[classical-list-item]');
?>
</div>
<?php
}
?>
</div>
</div>
</section>
<!-- ============================ Listings End ================================== -->
<?php
}
}
Thanks for the help in clarifying
I have a problem that is driving me crazy. I'm working on a business listing website in WordPress which allows business users to upload their businesses, along with a description and an image.
All was working fine in development but as soon as a SSL is installed on the site, image uploads produce an error:
An error occurred in the upload. Please try again later.
The inspector console shows:
400 error: Failed to load resource: the server responded with a status of 400 (Bad Request)
and the file cannot be uploaded.
I'm out of my depth here - any ideas please?
I think this is the relevant part of the theme library - not sure it it helps?
<?php
if ( ! search_and_go_elated_listing_plugin_installed() ) {
//exit if listing plugin is not installed
return;
}
if(!function_exists('search_and_go_elated_map_listing_type_settings')) {
function search_and_go_elated_map_listing_type_settings() {
$meta_box_listing_type = search_and_go_elated_create_meta_box(array(
'scope' => 'listing-type-item',
'title' => 'Listing Type Settings',
'name' => 'listing_type_settings_meta_box'
));
search_and_go_elated_create_meta_box_field(array(
'name' => 'eltd_listing_type_show_phone',
'type' => 'yesno',
'label' => esc_html__( 'Show Phone Field', 'search-and-go' ),
'default_value' => 'yes',
'parent' => $meta_box_listing_type
));
search_and_go_elated_create_meta_box_field(array(
'name' => 'eltd_listing_type_show_website',
'type' => 'yesno',
'label' => esc_html__( 'Show Website Field', 'search-and-go' ),
'default_value' => 'yes',
'parent' => $meta_box_listing_type
));
search_and_go_elated_create_meta_box_field(array(
'name' => 'eltd_listing_type_show_email',
'type' => 'yesno',
'label' => esc_html__( 'Show Email Field', 'search-and-go' ),
'default_value' => 'yes',
'parent' => $meta_box_listing_type
));
search_and_go_elated_create_meta_box_field(array(
'name' => 'eltd_listing_type_show_gallery',
'type' => 'yesno',
'label' => esc_html__( 'Show Gallery Images', 'search-and-go' ),
'default_value' => 'yes',
'parent' => $meta_box_listing_type
));
search_and_go_elated_create_meta_box_field(array(
'name' => 'eltd_listing_type_show_video',
'type' => 'yesno',
'label' => esc_html__( 'Show Video', 'search-and-go' ),
'default_value' => 'yes',
'parent' => $meta_box_listing_type
));
search_and_go_elated_create_meta_box_field(array(
'name' => 'eltd_listing_type_show_audio',
'type' => 'yesno',
'label' => esc_html__( 'Show Audio', 'search-and-go' ),
'default_value' => 'yes',
'parent' => $meta_box_listing_type
));
search_and_go_elated_create_meta_box_field(array(
'name' => 'eltd_listing_type_show_work_hours',
'type' => 'yesno',
'label' => esc_html__( 'Show Working Hours', 'search-and-go' ),
'default_value' => 'yes',
'parent' => $meta_box_listing_type
));
search_and_go_elated_create_meta_box_field(array(
'name' => 'eltd_listing_type_show_social_icons',
'type' => 'yesno',
'label' => esc_html__( 'Show Social Icons', 'search-and-go' ),
'default_value' => 'yes',
'parent' => $meta_box_listing_type
));
search_and_go_elated_create_meta_box_field(array(
'name' => 'eltd_listing_type_show_price',
'type' => 'yesno',
'label' => esc_html__( 'Show Price', 'search-and-go' ),
'default_value' => 'yes',
'parent' => $meta_box_listing_type
));
search_and_go_elated_create_meta_box_field(array(
'name' => 'eltd_listing_type_show_sidebar_gallery',
'type' => 'yesno',
'label' => esc_html__( 'Show Sidebar Gallery', 'search-and-go' ),
'description' => '',
'default_value' => 'yes',
'parent' => $meta_box_listing_type
));
search_and_go_elated_create_meta_box_field(array(
'name' => 'eltd_listing_type_show_booking_form',
'type' => 'yesno',
'label' => esc_html__( 'Show Booking Form', 'search-and-go' ),
'description' => esc_html__( 'Requires Elated Booking Plugin to be installed', 'search-and-go' ),
'default_value' => 'yes',
'parent' => $meta_box_listing_type
));
//init icon pack hide and show array. It will be populated dinamically from collections array
$listing_type_icon_pack_hide_array = array();
$listing_type_icon_pack_show_array = array();
//do we have some collection added in collections array?
if (is_array(search_and_go_elated_icon_collections()->iconCollections) && count(search_and_go_elated_icon_collections()->iconCollections)) {
//get collections params array. It will contain values of 'param' property for each collection
$listing_type_icon_collections_params = search_and_go_elated_icon_collections()->getIconCollectionsParams();
//foreach collection generate hide and show array
foreach (search_and_go_elated_icon_collections()->iconCollections as $dep_collection_key => $dep_collection_object) {
$listing_type_icon_pack_hide_array[$dep_collection_key] = '';
//we need to include only current collection in show string as it is the only one that needs to show
$listing_type_icon_pack_show_array[$dep_collection_key] = '#eltd_listing_type_icon_' . $dep_collection_object->param . '_container';
//for all collections param generate hide string
foreach ($listing_type_icon_collections_params as $listing_icon_collections_param) {
//we don't need to include current one, because it needs to be shown, not hidden
if ($listing_icon_collections_param !== $dep_collection_object->param) {
$listing_type_icon_pack_hide_array[$dep_collection_key] .= '#eltd_listing_type_icon_' . $listing_icon_collections_param . '_container,';
}
}
//remove remaining ',' character
$listing_type_icon_pack_hide_array[$dep_collection_key] = rtrim($listing_type_icon_pack_hide_array[$dep_collection_key], ',');
}
}
search_and_go_elated_create_meta_box_field(
array(
'parent' => $meta_box_listing_type,
'type' => 'select',
'name' => 'listing_type_icon_pack',
'default_value' => 'font_awesome',
'label' => esc_html__( 'Listing Type Icon Pack', 'search-and-go' ),
'description' => esc_html__( 'Choose icon pack for listing', 'search-and-go' ),
'options' => search_and_go_elated_icon_collections()->getIconCollections(),
'args' => array(
'dependence' => true,
'hide' => $listing_type_icon_pack_hide_array,
'show' => $listing_type_icon_pack_show_array
)
)
);
if (is_array(search_and_go_elated_icon_collections()->iconCollections) && count(search_and_go_elated_icon_collections()->iconCollections)) {
//foreach icon collection we need to generate separate container that will have dependency set
//it will have one field inside with icons dropdown
foreach (search_and_go_elated_icon_collections()->iconCollections as $collection_key => $collection_object) {
$icons_array = $collection_object->getIconsArray();
//get icon collection keys (keys from collections array, e.g 'font_awesome', 'font_elegant' etc.)
$icon_collections_keys = search_and_go_elated_icon_collections()->getIconCollectionsKeys();
//unset current one, because it doesn't have to be included in dependency that hides icon container
unset($icon_collections_keys[array_search($collection_key, $icon_collections_keys)]);
$listing_icon_hide_values = $icon_collections_keys;
$listing_icon_container = search_and_go_elated_add_admin_container(
array(
'parent' => $meta_box_listing_type,
'name' => 'listing_type_icon_' . $collection_object->param . '_container',
'hidden_property' => 'listing_type_icon_pack',
'hidden_value' => '',
'hidden_values' => $listing_icon_hide_values
)
);
search_and_go_elated_create_meta_box_field(
array(
'parent' => $listing_icon_container,
'type' => 'select',
'name' => 'listing_type_icon_' . $collection_object->param,
'default_value' => '',
'label' => esc_html__( 'Listing Type Icon', 'search-and-go' ),
'description' => esc_html__( 'Choose Listing Type Icon', 'search-and-go' ),
'options' => $icons_array,
)
);
}
}
search_and_go_elated_add_custom_fields_creator(array(
'name' => 'listing_custom_fields' ,
'label' => esc_html__( 'Custom Fields Creator', 'search-and-go' ),
'desciption' => esc_html__( 'Create listing type custom fields', 'search-and-go' ),
'parent' => $meta_box_listing_type
));
$feature_list_title = search_and_go_elated_add_admin_section_title(
array(
'parent' => $meta_box_listing_type,
'title' => esc_html__( 'Listing Type Feature List', 'search-and-go' ),
'name' => 'listing_type_feature_list_title'
)
);
search_and_go_elated_add_repeater_field(array(
'name' => 'eltd_listing_type_repeater',
'parent' => $meta_box_listing_type,
'fields' => array(
array(
'type' => 'textsimple',
'name' => 'eltd_listing_type_feature_list',
'label' => '',
'description' => '',
),
)
)
);
}
add_action('search_and_go_elated_meta_boxes_map', 'search_and_go_elated_map_listing_type_settings');
}
I'm developing a child theme of a premium template, this comes with a custom post type with the label name of "release" but I'd like to change it to something else, I know that if I go to the functions.php file of the main theme I can change it easily but I'd like to change it from my child theme?
here is the code
<?php
add_action('init', 'kentha_release_register_type');
if(!function_exists('kentha_release_register_type')){
function kentha_release_register_type() {
$labelsrelease = array(
'name' => esc_html__("Release",'kentha'),
'singular_name' => esc_html__("Release",'kentha'),
'add_new' => esc_html__("Add new",'kentha'),
'add_new_item' => esc_html__("Add new release",'kentha'),
'edit_item' => esc_html__("Edit release",'kentha'),
'new_item' => esc_html__("New release",'kentha'),
'all_items' => esc_html__("All releases",'kentha'),
'view_item' => esc_html__("View release",'kentha'),
'search_items' => esc_html__("Search release",'kentha'),
'not_found' => esc_html__("No releases found",'kentha'),
'not_found_in_trash' => esc_html__("No releases found in trash",'kentha'),
'menu_name' => esc_html__("Album releases",'kentha')
);
$args = array(
'labels' => $labelsrelease,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'page',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => 40,
'page-attributes' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'show_in_menu' => true,
'menu_icon' => 'dashicons-controls-play',
'supports' => array('title', 'thumbnail','editor', 'page-attributes' )
);
if (function_exists('ttg_custom_post_type')){
ttg_custom_post_type( "release" , $args );
}
/* ============= create custom taxonomy for the releases ==========================*/
$labels = array(
'name' => __( 'Release genres','kentha' ),
'singular_name' => esc_html__( 'Genre','kentha' ),
'search_items' => esc_html__( 'Search by genre','kentha' ),
'popular_items' => esc_html__( 'Popular genres','kentha' ),
'all_items' => esc_html__( 'All releases','kentha' ),
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => esc_html__( 'Edit genre','kentha' ),
'update_item' => esc_html__( 'Update genre','kentha' ),
'add_new_item' => esc_html__( 'Add New genre','kentha' ),
'new_item_name' => esc_html__( 'New genre Name','kentha' ),
'separate_items_with_commas' => esc_html__( 'Separate genres with commas','kentha' ),
'add_or_remove_items' => esc_html__( 'Add or remove genres','kentha' ),
'choose_from_most_used' => esc_html__( 'Choose from the most used genres','kentha' ),
'menu_name' => esc_html__( 'Music genres','kentha' ),
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'update_count_callback' => '_update_post_term_count',
'query_var' => true,
'rewrite' => array( 'slug' => 'genre' ),
);
if(function_exists('ttg_custom_taxonomy')){
ttg_custom_taxonomy('genre','release',$args );
}
$fields = array(
array( // Repeatable & Sortable Text inputs
'label' => esc_html__( 'Release Tracks','kentha' ), // <label>
'desc' => esc_html__( 'Add one for each track in the release','kentha' ), // description
'id' => 'track_repeatable', // field id and name
'type' => 'repeatable', // type of field
'sanitizer' => array( // array of sanitizers with matching kets to next array
'featured' => 'meta_box_santitize_boolean',
'title' => 'sanitize_text_field',
'desc' => 'wp_kses_data'
),
'repeatable_fields' => array ( // array of fields to be repeated
'releasetrack_mp3_demo' => array(
'label' => esc_html__( 'MP3 Demo','kentha' ),
'desc' => esc_html__( '(Never upload your full quality tracks, someone can steal them)','kentha' ), // description
'id' => 'releasetrack_mp3_demo',
'type' => 'file'
),
'releasetrack_track_title' => array(
'label' => esc_html__( 'Title','kentha' ),
'id' => 'releasetrack_track_title',
'type' => 'text'
),
'releasetrack_artist_name' => array(
'label' => esc_html__( 'Artists','kentha' ),
'desc' => esc_html__( '(All artists separated bu comma)','kentha' ), // description
'id' => 'releasetrack_artist_name',
'type' => 'text'
),
'releasetrack_buy_url' => array(
'label' => esc_html__( 'Track Buy link','kentha' ),
'desc' => esc_html__( 'A link to buy the single track','kentha' ), // description
'id' => 'releasetrack_buyurl',
'type' => 'text'
),
'icon_type' => array(
'label' => esc_html__( 'Track icon (cart icon is default)','kentha' ),
'id' => 'icon_type',
'type' => 'select',
'default' => 'cart',
'options' => array(
array('label' => 'cart','value' => 'cart'),
array('label' => 'download','value' => 'download')
)
),
)
)
);
$fields_links = array(
array( // Repeatable & Sortable Text inputs
'label' => esc_html__( 'Custom Buy Links','kentha' ), // <label>
'desc' => esc_html__( 'Add one for each link to external websites','kentha' ), // description
'id' => 'track_repeatablebuylinks', // field id and name
'type' => 'repeatable', // type of field
'sanitizer' => array( // array of sanitizers with matching kets to next array
'featured' => 'meta_box_santitize_boolean',
'title' => 'sanitize_text_field',
'desc' => 'wp_kses_data'
),
'repeatable_fields' => array ( // array of fields to be repeated
'custom_buylink_anchor' => array(
'label' => esc_html__( 'Custom Buy Text','kentha' ),
'desc' => esc_html__( '(example: Itunes, Beatport, Trackitdown)','kentha' ),
'id' => 'cbuylink_anchor',
'type' => 'text'
),
'custom_buylink_url' => array(
'label' => esc_html__('Custom Buy URL','kentha' ),
'desc' => esc_html__( '(example: http://...)','kentha' ), // description
'id' => 'cbuylink_url',
'type' => 'text'
)
)
)
);
$fields_release = array(
array(
'label' => esc_html__('Main artist', "kentha"),
'id' => 'releasetrack_artist',
'type' => 'post_chosen',
'posttype' => 'artist'
),
array(
'label' => esc_html__( 'Label','kentha' ),
'id' => 'general_release_details_label',
'type' => 'text'
),
array(
'label' =>esc_html__( 'Release date (YYYY-MM-DD)','kentha' ) ,
'id' => 'general_release_details_release_date',
'type' => 'date'
),
array(
'label' => esc_html__( 'Catalog Number','kentha' ),
'id' => 'general_release_details_catalognumber',
'type' => 'text'
)
);
$details_box = new custom_add_meta_box( 'release_details', 'Release Details', $fields_release, 'release', true );
$sample_box = new custom_add_meta_box( 'release_tracks', 'Release Tracks', $fields, 'release', true );
$buylinks_box = new custom_add_meta_box( 'release_buylinkss', 'Custom Buy Links', $fields_links, 'release', true );
}}
I need to update in Child Teme the icon_type options adding this extra fields
array('label' => 'spotify','value' => 'spotify')
Any suggestion?
Thanks in advance
I want to change the text label from "Cash on Delivery" to "Pay Cash in Person", but I can't figure out how to target a hook and make these changes. I know that I should be targeting the 'default' within 'title' => array(), but not sure how to go about this.
$this->form_fields = array(
'enabled' => array(
'title' => __( 'Enable/Disable', 'woocommerce' ),
'label' => __( 'Enable cash on delivery', 'woocommerce' ),
'type' => 'checkbox',
'description' => '',
'default' => 'no',
),
'title' => array(
'title' => __( 'Title', 'woocommerce' ),
'type' => 'text',
'description' => __( 'Payment method description that the customer will see on your checkout.', 'woocommerce' ),
'default' => __( 'Cash on delivery', 'woocommerce' ),
'desc_tip' => true,
),
'description' => array(
'title' => __( 'Description', 'woocommerce' ),
'type' => 'textarea',
'description' => __( 'Payment method description that the customer will see on your website.', 'woocommerce' ),
'default' => __( 'Pay with cash upon delivery.', 'woocommerce' ),
'desc_tip' => true,
),
add_filter( 'rwmb_meta_boxes', 'your_prefix_meta_boxes' );
function your_prefix_meta_boxes( $meta_boxes ) {
$meta_boxes[] = array(
'title' => __( 'Custom theme 2 Metabox ', 'textdomain' ),
'post_types' => array('page'),
'fields' => array(
array(
'id' => 'htitle',
'name' => __( 'Home Page Title ', 'textdomain' ),
'type' => 'text',
),
array(
'id' => 'titlecss',
'name' => __( 'Title CSS', 'textdomain' ),
'type' => 'checkbox',
'desc' => __( 'CSS For "WELCOME TO"', 'your-prefix' ),
),
array(
'id' => 'titlecss2',
'name' => __( 'Title CSS2', 'textdomain' ),
'type' => 'checkbox',
'desc' => __( 'CSS For "Company name"', 'your-prefix' ),
),
),
);
return $meta_boxes;
}
help to get checkbox value i got value of text box like this
<?php echo rwmb_meta( 'htitle' ); ?>
but i m not able to fetch value of checkbox please help
<?php echo rwmb_meta( 'titlecss' ); ?
i got it by using id of checkbox