SSL breaks a users ability to upload an image - wordpress

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');
}

Related

Wordpress add Shortcut link to Enable/Disable plugin in admin bar

I would like to add a link to enable and disable a plugin in the admin bar.
Below the code, I wanted to know if it is the correct method.
thank you
function custom_admin_bar_link( $admin_bar ) {
$admin_bar->add_menu( array(
'id' => 'wp-custom-link',
'title' => 'Custom Item',
'href' => '',
'meta' => array(
'title' => __('Custom'),
),
));
$admin_bar->add_menu( array(
'id' => 'disable-link',
'parent'=> 'wp-custom-link',
'title' => 'Disable Amazon',
'href' => 'https://mydisablelink.com/',
'meta' => array(
'title' => __('Disable Amazon'),
),
));
$admin_bar->add_menu( array(
'id' => 'unable-link',
'parent'=> 'wp-custom-link',
'title' => 'Enable Amazon',
'href' => 'https://mydisablelink.com/',
'meta' => array(
'title' => __('Enable Amazon'),
),
));
}
add_action( 'admin_bar_menu', 'custom_admin_bar_link', 100 );

How to add custom fields in ACF programmatically?

I want to programmatically add a tab with repeater inside but I can't seem to find a solution, I've googled all available resources but still not working.
I already tried using acf_add_local_field_group and acf_add_local_field but still no luck.
Well I can create a tab using acf_add_local_field but when I tried to add a child which in this case a repeater OR even a text field it still doesn't work.
Here's my code to create a tab and its child but the child doesn't work.
acf_add_local_field(array(
'key' => 'field_1',
'label' => 'Sub Title',
'name' => 'sub_title',
'type' => '',
'parent' => 'field_5bd14c9349930',
'fields' => array (
array(
'key' => 'field_2',
'label' => 'This is a test',
'name' => 'my_test',
'type' => 'text',
)
)
));
You should use acf_add_local_field_group to construct the whole field group.
Here's the proper code for adding a group and a custom tab with single repeater field inside:
if( function_exists('acf_add_local_field_group') ):
acf_add_local_field_group(array (
'key' => 'group_1',
'title' => 'My Group',
'fields' => array (
array (
'key' => 'field_unique_key',
'label' => 'First Tab',
'name' => '',
'type' => 'tab',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
'placement' => 'top',
'endpoint' => 0,
),
array (
'key' => 'field_unique_key',
'label' => 'Simple Repeater',
'name' => 'simple_repeater',
'type' => 'repeater',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
'collapsed' => '',
'min' => 0,
'max' => 10,
'layout' => 'table',
'button_label' => 'Add row',
'sub_fields' => array ( // Here you can add as many subfields for this repeater as you want
array (
'key' => 'field_unique_key',
'label' => 'Link',
'name' => 'link',
'type' => 'link', // example link type
'instructions' => 'Link name and URL',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
'return_format' => 'array',
),
),
),
),
'location' => array (
array (
array (
'param' => 'post_type',
'operator' => '==',
'value' => 'post',
),
),
),
'menu_order' => 0,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
));
endif;

Update Parent post type in child theme

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

How can i use Option Tree custom post type checkbox in wordpress

array(
'id' => 'custom_post_type_checkbox',
'label' => __( 'Custom Post Type Select', 'theme-text-domain' ),
'desc' => sprintf( __( 'Check box' ),
'std' => '',
'type' => 'custom-post-type-checkbox',
'section' => '',
'rows' => '',
'post_type' => 'newyork-offices',
'taxonomy' => '',
'min_max_step'=> '',
'class' => '',
'condition' => '',
'operator' => 'and'
),
This is custom post type check box and i got all posts in my page template. so How can i use it my page template ?
What is the loop function for this ?

get acf fields from php file

I put this code into my functions.php
include_once('advanced-custom-fields/acf.php');
include_once('acf-options-page/acf-options-page.php');
include_once('acf-repeater/acf-repeater.php');
define( 'ACF_LITE', true );
if(function_exists("register_field_group"))
{
register_field_group(array (
'id' => 'acf_options',
'title' => 'Options',
'fields' => array (
array (
'key' => 'field_525d1b6d49043',
'label' => 'lable',
'name' => 'homepage',
'type' => 'repeater',
'instructions' => 'Select which categories you want to display on the homepage.',
'sub_fields' => array (
array (
'key' => 'field_525d1b8a49044',
'label' => 'Category',
'name' => 'firsttext',
'type' => 'text',
'column_width' => '',
'field_type' => 'text',
'return_format' => 'id',
),
array (
'key' => 'field_525d2473de72c',
'label' => 'Number of Posts',
'name' => 'number-of-posts',
'type' => 'text',
'column_width' => '',
'default_value' => 4,
'placeholder' => '',
'prepend' => '',
'append' => '',
'min' => 2,
'max' => '',
'step' => 2,
),
),
'row_min' => 1,
'row_limit' => 1,
'layout' => 'row',
'button_label' => 'Add a category',
),
),
'location' => array (
array (
array (
'param' => 'options_page',
'operator' => '==',
'value' => 'acf-options',
'order_no' => 0,
'group_no' => 0,
),
),
),
'options' => array (
'position' => 'normal',
'layout' => 'no_box',
'hide_on_screen' => array (
),
),
'menu_order' => 0,
));
}
Then I enter values into fields in admin console
How I cat get this value from page file?
I try get_field('acf_options) and I try get_field('homepage), but this return null
Im not sure why you would want to put this in your function.php file instead of just do this this through the plugin.
But if you want to retrieve those field values, you should do this: get_field( 'homepage', 'option' );
instead of:
get_field( 'homepage' ) or get_field( 'acf_options' );
My best advice would be to look on the ACF website for information. These docs help out a lot!

Resources