Skip to content

Commit

Permalink
fixed wc session bug
Browse files Browse the repository at this point in the history
  • Loading branch information
eclipsesrl committed Aug 20, 2019
1 parent 8f54b3a commit b3f876e
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 102 deletions.
5 changes: 4 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Donate link: https://www.udesly.com/
Tags: webflow to wordpress, editor, page builder, layout design, udesly, webflow
Requires at least: 5.0
Tested up to: 5.2.2
Stable tag: 2.0.0.11
Stable tag: 2.0.0.12
License: GPLv3 or later
License URI: https://www.udesly.com/terms-conditions-of-use/#udesly-wordpress-plugin
Requires PHP: 5.6.0
Expand Down Expand Up @@ -81,6 +81,9 @@ Thats' all!
Absolutely! You can use the Udesly Adapter to create more than one website.
== Changelog ==

= 2.0.0.12 =
* added check for WC session on wc alternative template

= 2.0.0.11 =
* Fixed more typos in Webflow data view.

Expand Down
204 changes: 106 additions & 98 deletions includes/CPT/CustomPostTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,95 +23,97 @@ public static function init_all_custom_post_types()
$taxonomies = explode(",", $options['taxonomies']);

$labels = array(
'name' => $options['plural'],
'singular_name' => $options['singular'],
'menu_name' => ucfirst($options['plural']),
'name_admin_bar' => $options['singular'],
'archives' => $options['singular'] . __( 'Archives',UDESLY_TEXT_DOMAIN ),
'attributes' => $options['singular'] . __( 'Attributes',UDESLY_TEXT_DOMAIN ),
'parent_item_colon' => __( 'Parent Item:',UDESLY_TEXT_DOMAIN ),
'all_items' => __( 'All ',UDESLY_TEXT_DOMAIN ) . $options['plural'],
'add_new_item' => __( 'Add New ',UDESLY_TEXT_DOMAIN ) . $options['singular'],
'add_new' => __( 'Add New',UDESLY_TEXT_DOMAIN ),
'new_item' => __( 'New ',UDESLY_TEXT_DOMAIN ) . $options['singular'],
'edit_item' => __( 'Edit ',UDESLY_TEXT_DOMAIN ) . $options['singular'],
'update_item' => __( 'Update ',UDESLY_TEXT_DOMAIN ) . $options['singular'],
'view_item' => __( 'View ',UDESLY_TEXT_DOMAIN ) . $options['singular'],
'view_items' => __( 'View ',UDESLY_TEXT_DOMAIN ) . $options['plural'],
'search_items' => __( 'Search ',UDESLY_TEXT_DOMAIN ) . $options['singular'],
'not_found' => __( 'Not found',UDESLY_TEXT_DOMAIN ),
'not_found_in_trash' => __( 'Not found in Trash',UDESLY_TEXT_DOMAIN ),
'featured_image' => __( 'Featured Image',UDESLY_TEXT_DOMAIN ),
'set_featured_image' => __( 'Set featured image',UDESLY_TEXT_DOMAIN ),
'remove_featured_image' => __( 'Remove featured image',UDESLY_TEXT_DOMAIN ),
'use_featured_image' => __( 'Use as featured image',UDESLY_TEXT_DOMAIN ),
'insert_into_item' => __( 'Insert into item',UDESLY_TEXT_DOMAIN ),
'uploaded_to_this_item' => __( 'Uploaded to this item',UDESLY_TEXT_DOMAIN ),
'items_list' => __( 'Items list',UDESLY_TEXT_DOMAIN ),
'items_list_navigation' => __( 'Items list navigation',UDESLY_TEXT_DOMAIN ),
'filter_items_list' => __( 'Filter items list',UDESLY_TEXT_DOMAIN ),
'name' => $options['plural'],
'singular_name' => $options['singular'],
'menu_name' => ucfirst($options['plural']),
'name_admin_bar' => $options['singular'],
'archives' => $options['singular'] . __('Archives', UDESLY_TEXT_DOMAIN),
'attributes' => $options['singular'] . __('Attributes', UDESLY_TEXT_DOMAIN),
'parent_item_colon' => __('Parent Item:', UDESLY_TEXT_DOMAIN),
'all_items' => __('All ', UDESLY_TEXT_DOMAIN) . $options['plural'],
'add_new_item' => __('Add New ', UDESLY_TEXT_DOMAIN) . $options['singular'],
'add_new' => __('Add New', UDESLY_TEXT_DOMAIN),
'new_item' => __('New ', UDESLY_TEXT_DOMAIN) . $options['singular'],
'edit_item' => __('Edit ', UDESLY_TEXT_DOMAIN) . $options['singular'],
'update_item' => __('Update ', UDESLY_TEXT_DOMAIN) . $options['singular'],
'view_item' => __('View ', UDESLY_TEXT_DOMAIN) . $options['singular'],
'view_items' => __('View ', UDESLY_TEXT_DOMAIN) . $options['plural'],
'search_items' => __('Search ', UDESLY_TEXT_DOMAIN) . $options['singular'],
'not_found' => __('Not found', UDESLY_TEXT_DOMAIN),
'not_found_in_trash' => __('Not found in Trash', UDESLY_TEXT_DOMAIN),
'featured_image' => __('Featured Image', UDESLY_TEXT_DOMAIN),
'set_featured_image' => __('Set featured image', UDESLY_TEXT_DOMAIN),
'remove_featured_image' => __('Remove featured image', UDESLY_TEXT_DOMAIN),
'use_featured_image' => __('Use as featured image', UDESLY_TEXT_DOMAIN),
'insert_into_item' => __('Insert into item', UDESLY_TEXT_DOMAIN),
'uploaded_to_this_item' => __('Uploaded to this item', UDESLY_TEXT_DOMAIN),
'items_list' => __('Items list', UDESLY_TEXT_DOMAIN),
'items_list_navigation' => __('Items list navigation', UDESLY_TEXT_DOMAIN),
'filter_items_list' => __('Filter items list', UDESLY_TEXT_DOMAIN),
);

$args = array(
'label' => $options['singular'],
'description' => "",
'labels' => $labels,
'supports' => array( 'title', 'author', 'editor', 'thumbnail', 'custom-fields', 'excerpt' ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => true,
'rewrite' => array(
'slug' => $options['archive_rewrite'],
$args = array(
'label' => $options['singular'],
'description' => "",
'labels' => $labels,
'supports' => array('title', 'author', 'editor', 'thumbnail', 'custom-fields', 'excerpt'),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => true,
'rewrite' => array(
'slug' => $options['archive_rewrite'],
'with_front' => true,
'pages' => true,
'feeds' => true
'pages' => true,
'feeds' => true
),
'show_in_rest' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'page',
'menu_icon' => $options['icon']
'publicly_queryable' => true,
'capability_type' => 'page',
'menu_icon' => $options['icon']
);

$args = apply_filters("udesly_register_custom_post_type_args_$type", $args);
register_post_type($type, $args );


foreach ( $taxonomies as $taxonomy ) {
$taxonomy = sanitize_title( trim( $taxonomy ) );
$taxonomy = str_replace( '-', '_', $taxonomy );
$tax_name = str_replace( '_', ' ', ucfirst( $taxonomy ) );
$slug = get_option('udesly_cpt_rewrite_' . $type . '_' . $taxonomy . '_field_id', $type . '_' . $taxonomy);
// var_dump('udesly_cpt_rewrite_' . $type . '_' . $taxonomy . '_field_id');
$registered_taxonomies[$type . '_' . $taxonomy] = $type;
register_taxonomy( $type . '_' . $taxonomy, $type, array(
'labels' => array(
'name' => $tax_name,
'singular_name' => $tax_name,
'menu_name' => __( 'All ', UDESLY_TEXT_DOMAIN ) . $tax_name,
'all_items' => __( 'All ', UDESLY_TEXT_DOMAIN ) . $tax_name,
'edit_item' => __( 'Edit ', UDESLY_TEXT_DOMAIN ) . $tax_name,
'view_item' => __( 'View ', UDESLY_TEXT_DOMAIN ) . $tax_name,
'update_item' => __( 'Update ', UDESLY_TEXT_DOMAIN ) . $tax_name,
'add_new_item' => __( 'Add new ', UDESLY_TEXT_DOMAIN ) . $tax_name,
'new_item_name' => __( 'New ', UDESLY_TEXT_DOMAIN ) . $tax_name . __( ' name', UDESLY_TEXT_DOMAIN ),
'search_items' => __( 'Search ', UDESLY_TEXT_DOMAIN ) . $tax_name,
'popular_items' => __( 'Popular ', UDESLY_TEXT_DOMAIN ) . $tax_name,
'separate_items_with_commas' => __( 'Separate ', UDESLY_TEXT_DOMAIN ) . $tax_name . __( ' with commas', UDESLY_TEXT_DOMAIN ),
'add_or_remove_items' => __( 'Add or remove ', UDESLY_TEXT_DOMAIN ) . $tax_name,
'choose_from_most_used' => __( 'Choose most used ', UDESLY_TEXT_DOMAIN ) . $tax_name,
'not_found' => __( 'No ', UDESLY_TEXT_DOMAIN ) . $tax_name . __( ' found', UDESLY_TEXT_DOMAIN ),
),
'rewrite' => array(
'slug' => $slug
)
) );
register_post_type($type, $args);


foreach ($taxonomies as $taxonomy) {
$taxonomy = sanitize_title(trim($taxonomy));
if ($taxonomy) {
$taxonomy = str_replace('-', '_', $taxonomy);
$tax_name = str_replace('_', ' ', ucfirst($taxonomy));
$slug = get_option('udesly_cpt_rewrite_' . $type . '_' . $taxonomy . '_field_id', $type . '_' . $taxonomy);
// var_dump('udesly_cpt_rewrite_' . $type . '_' . $taxonomy . '_field_id');
$registered_taxonomies[$type . '_' . $taxonomy] = $type;
register_taxonomy($type . '_' . $taxonomy, $type, array(
'labels' => array(
'name' => $tax_name,
'singular_name' => $tax_name,
'menu_name' => __('All ', UDESLY_TEXT_DOMAIN) . $tax_name,
'all_items' => __('All ', UDESLY_TEXT_DOMAIN) . $tax_name,
'edit_item' => __('Edit ', UDESLY_TEXT_DOMAIN) . $tax_name,
'view_item' => __('View ', UDESLY_TEXT_DOMAIN) . $tax_name,
'update_item' => __('Update ', UDESLY_TEXT_DOMAIN) . $tax_name,
'add_new_item' => __('Add new ', UDESLY_TEXT_DOMAIN) . $tax_name,
'new_item_name' => __('New ', UDESLY_TEXT_DOMAIN) . $tax_name . __(' name', UDESLY_TEXT_DOMAIN),
'search_items' => __('Search ', UDESLY_TEXT_DOMAIN) . $tax_name,
'popular_items' => __('Popular ', UDESLY_TEXT_DOMAIN) . $tax_name,
'separate_items_with_commas' => __('Separate ', UDESLY_TEXT_DOMAIN) . $tax_name . __(' with commas', UDESLY_TEXT_DOMAIN),
'add_or_remove_items' => __('Add or remove ', UDESLY_TEXT_DOMAIN) . $tax_name,
'choose_from_most_used' => __('Choose most used ', UDESLY_TEXT_DOMAIN) . $tax_name,
'not_found' => __('No ', UDESLY_TEXT_DOMAIN) . $tax_name . __(' found', UDESLY_TEXT_DOMAIN),
),
'rewrite' => array(
'slug' => $slug
)
));
}
}

}
Expand All @@ -122,22 +124,26 @@ public static function init_all_custom_post_types()
}

/* Setting Section Description */
public static function taxonomy_rewrite_slug(){
echo wpautop( "Change the permalink structure" );
public static function taxonomy_rewrite_slug()
{
echo wpautop("Change the permalink structure");
}

/* Settings Field Callback */
public static function taxonomy_rewrite_slug_field($args){
public static function taxonomy_rewrite_slug_field($args)
{
?>
<input id="<?php echo $args[0]; ?>" type="text" value="<?php echo get_option($args[0], $args[1]); ?>" name="<?php echo $args[0]; ?>" />
<input id="<?php echo $args[0]; ?>" type="text" value="<?php echo get_option($args[0], $args[1]); ?>"
name="<?php echo $args[0]; ?>"/>
<?php
}

public static function rewrite_custom_taxonomies() {
public static function rewrite_custom_taxonomies()
{
$cached_types = wp_cache_get('udesly_registered_types');
$cached_taxonomies = wp_cache_get('udesly_registered_taxonomies');

if(!$cached_taxonomies || !$cached_types) {
if (!$cached_taxonomies || !$cached_types) {
return;
}

Expand All @@ -151,7 +157,7 @@ public static function rewrite_custom_taxonomies() {
}


foreach ($cached_taxonomies as $taxonomy => $type){
foreach ($cached_taxonomies as $taxonomy => $type) {

$option_name = 'udesly_cpt_rewrite_' . $taxonomy . '_field_id';

Expand All @@ -173,13 +179,14 @@ public static function rewrite_custom_taxonomies() {
);

//Register settings in DB (is not possible to do with Settings API in permalink page, WP BUG)
if(isset($_POST[$option_name])){
update_option($option_name,sanitize_title($_POST[$option_name]));
if (isset($_POST[$option_name])) {
update_option($option_name, sanitize_title($_POST[$option_name]));
}
}
}

public static function add_registered_taxonomies_to_featured_image( $post_types ) {
public static function add_registered_taxonomies_to_featured_image($post_types)
{
$registered_taxonomies = wp_cache_get('udesly_registered_taxonomies');

if ($registered_taxonomies) {
Expand All @@ -196,25 +203,26 @@ public static function admin_hooks()
add_filter('udesly_attach_featured_image_terms', array(self::class, "add_registered_taxonomies_to_featured_image"), 1, 1);
}

public static function custom_taxonomy_archive( $template ) {
public static function custom_taxonomy_archive($template)
{
$obj = get_queried_object();

if(!$obj) {
if (!$obj) {
return $template;
}

$cached_taxonomies = wp_cache_get('udesly_registered_taxonomies');

if(!$cached_taxonomies) {
if (!$cached_taxonomies) {
return $template;
}

if( isset($obj->taxonomy) &&
if (isset($obj->taxonomy) &&
taxonomy_exists($obj->taxonomy) && isset($cached_taxonomies[$obj->taxonomy]) &&
file_exists(get_template_directory(). '/archive-' . $cached_taxonomies[$obj->taxonomy] . '.php' )){
file_exists(get_template_directory() . '/archive-' . $cached_taxonomies[$obj->taxonomy] . '.php')) {

$new_template = locate_template( array( 'archive-' . $cached_taxonomies[$obj->taxonomy] . '.php' ) );
if ( !empty( $new_template ) ) {
$new_template = locate_template(array('archive-' . $cached_taxonomies[$obj->taxonomy] . '.php'));
if (!empty($new_template)) {
return $new_template;
}
}
Expand All @@ -224,7 +232,7 @@ public static function custom_taxonomy_archive( $template ) {
public static function public_hooks()
{
add_action('init', array(self::class, 'init_all_custom_post_types'));
add_filter( 'template_include', array(self::class, 'custom_taxonomy_archive'), 98 );
add_filter('template_include', array(self::class, 'custom_taxonomy_archive'), 98);
}

}
2 changes: 1 addition & 1 deletion includes/misc/woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ function udesly_wc_alternative_template($located, $template_name, $args, $templa

global $udesly_checkout_classes;

if(!isset($udesly_checkout_classes)) {
if(!isset($udesly_checkout_classes) && WC()->session != null) {
$udesly_checkout_classes = WC()->session->get( 'udesly_checkout_classes' );
}

Expand Down
4 changes: 2 additions & 2 deletions udesly-adapter-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Plugin Name: Udesly Adapter
* Plugin URI: https://www.udesly.com
* Description: This is a support plugin for Udesly (Webflow to WordPress converter) that allows you to enable additional features for your theme.
* Version: 2.0.0.11
* Version: 2.0.0.12
* Author: Udesly
* Author URI: https://www.udesly.com
* License: GPL-2.0+
Expand All @@ -29,7 +29,7 @@
// Constants
defined('UDESLY_ADAPTER_PLUGIN_DIRECTORY_PATH') ?: define('UDESLY_ADAPTER_PLUGIN_DIRECTORY_PATH', plugin_dir_path(__FILE__));
defined('UDESLY_ADAPTER_PLUGIN_DIRECTORY_URL') ?: define('UDESLY_ADAPTER_PLUGIN_DIRECTORY_URL', plugin_dir_url(__FILE__));
defined('UDESLY_ADAPTER_VERSION') ?: define('UDESLY_ADAPTER_VERSION', "2.0.0.11");
defined('UDESLY_ADAPTER_VERSION') ?: define('UDESLY_ADAPTER_VERSION', "2.0.0.12");
defined('UDESLY_TEXT_DOMAIN') ?: define('UDESLY_TEXT_DOMAIN', "udesly-adapter-plugin");

defined('UDESLY_ADAPTER_PLUGIN_MISC_PATH') ?: define('UDESLY_ADAPTER_PLUGIN_MISC_PATH', plugin_dir_path(__FILE__) . 'includes/misc/');
Expand Down

0 comments on commit b3f876e

Please sign in to comment.