@@ -156,7 +156,6 @@ |
||
| 156 | 156 | /** |
| 157 | 157 | * Retourne une liste de taxinomies selon les paramètres donnés / Return a taxonomy list according to given parameters |
| 158 | 158 | * |
| 159 | - * @param array $args_where Optionnal Les paramètres du filtre permettant de récupérer les taxinomies / Parameters allowing to retrieve taxonomies |
|
| 160 | 159 | * @param boolean $cropped Optionnal Permet de choisir si il faut retourner la taxinomie complète ou uniquement les chamsp principaux / Allow to define if the taxonomy must be completly returned or just main fileds must be returned |
| 161 | 160 | * |
| 162 | 161 | * @return array La liste des taxinomies correspondantes aux paramètres / Taxonomies corresping to parameters |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | /** |
| 3 | 3 | * Fichier de gestion du modèle des taxinomies / File for term model management |
| 4 | 4 | * |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | public function __construct() { |
| 55 | 55 | /** Ajout des routes personnalisées pour les éléments de type "term" / Add specific routes for "term" elements' type */ |
| 56 | - add_filter( 'json_endpoints', array( &$this, 'callback_register_route' ) ); |
|
| 56 | + add_filter('json_endpoints', array(&$this, 'callback_register_route')); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
@@ -63,20 +63,20 @@ discard block |
||
| 63 | 63 | * |
| 64 | 64 | * @return Object L'objet sauvegardé / The saved object |
| 65 | 65 | */ |
| 66 | - public function update( $data ) { |
|
| 66 | + public function update($data) { |
|
| 67 | 67 | $object = $data; |
| 68 | 68 | |
| 69 | 69 | /** Dans le cas d'un tableau on le lit pour construire l'objet / If passed data is an array read and build an object from it */ |
| 70 | - if( is_array( $data ) ) { |
|
| 71 | - $object = new $this->model_name( $data, $this->meta_key ); |
|
| 70 | + if (is_array($data)) { |
|
| 71 | + $object = new $this->model_name($data, $this->meta_key); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** Sauvegarde des données dans la base de données / Save data into database */ |
| 75 | - $wp_category_danger = wp_update_term( $object->id, $this->get_taxonomy(), $object->do_wp_object() ); |
|
| 76 | - if ( !is_wp_error( $wp_category_danger ) ) { |
|
| 75 | + $wp_category_danger = wp_update_term($object->id, $this->get_taxonomy(), $object->do_wp_object()); |
|
| 76 | + if (!is_wp_error($wp_category_danger)) { |
|
| 77 | 77 | /** Mise à jour des options / Save options */ |
| 78 | - if( !empty( $object->option ) ) { |
|
| 79 | - $object->save_meta_data( $object, 'update_term_meta', $this->meta_key ); |
|
| 78 | + if (!empty($object->option)) { |
|
| 79 | + $object->save_meta_data($object, 'update_term_meta', $this->meta_key); |
|
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | |
@@ -90,26 +90,26 @@ discard block |
||
| 90 | 90 | * |
| 91 | 91 | * @return Object L'objet sauvegardé / The saved object |
| 92 | 92 | */ |
| 93 | - public function create( $data ) { |
|
| 93 | + public function create($data) { |
|
| 94 | 94 | $object = $data; |
| 95 | 95 | |
| 96 | - if( is_array( $data ) ) { |
|
| 97 | - $object = new $this->model_name( $data, $this->meta_key ); |
|
| 96 | + if (is_array($data)) { |
|
| 97 | + $object = new $this->model_name($data, $this->meta_key); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - $wp_category_danger = wp_insert_term( $object->name, $this->get_taxonomy(), array( |
|
| 100 | + $wp_category_danger = wp_insert_term($object->name, $this->get_taxonomy(), array( |
|
| 101 | 101 | 'description' => $object->description, |
| 102 | 102 | 'slug' => $object->slug, |
| 103 | 103 | 'parent' => $object->parent_id, |
| 104 | - ) ); |
|
| 104 | + )); |
|
| 105 | 105 | |
| 106 | - if ( !is_wp_error( $wp_category_danger ) ) { |
|
| 107 | - $object->id = $wp_category_danger[ 'term_id' ]; |
|
| 108 | - $object->term_taxonomy_id = $wp_category_danger[ 'term_taxonomy_id' ]; |
|
| 106 | + if (!is_wp_error($wp_category_danger)) { |
|
| 107 | + $object->id = $wp_category_danger['term_id']; |
|
| 108 | + $object->term_taxonomy_id = $wp_category_danger['term_taxonomy_id']; |
|
| 109 | 109 | |
| 110 | 110 | /** Mise à jour des options / Save options */ |
| 111 | - if( !empty( $object->option ) ) { |
|
| 112 | - $object->save_meta_data( $object, 'update_term_meta', $this->meta_key ); |
|
| 111 | + if (!empty($object->option)) { |
|
| 112 | + $object->save_meta_data($object, 'update_term_meta', $this->meta_key); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | return $object; |
@@ -127,8 +127,8 @@ discard block |
||
| 127 | 127 | * |
| 128 | 128 | * @param integer $id L'identifiant de la taxinomie a supprimer / The taxonomy identifier to delete |
| 129 | 129 | */ |
| 130 | - public function delete( $id ) { |
|
| 131 | - wp_delete_term( $id ); |
|
| 130 | + public function delete($id) { |
|
| 131 | + wp_delete_term($id); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
@@ -139,18 +139,18 @@ discard block |
||
| 139 | 139 | * |
| 140 | 140 | * @return object la taxinomie construite selon le modèle / The taxonomy builded according to the model |
| 141 | 141 | */ |
| 142 | - public function show( $id, $cropped = false ) { |
|
| 142 | + public function show($id, $cropped = false) { |
|
| 143 | 143 | /** Récupération de la taxinomie depuis wordpress / Get the taxonomy from wordpress */ |
| 144 | - $wp_term = get_term_by( 'id', $id, $this->taxonomy, OBJECT ); |
|
| 144 | + $wp_term = get_term_by('id', $id, $this->taxonomy, OBJECT); |
|
| 145 | 145 | |
| 146 | 146 | /** Construction de la taxinomie selon le modèle défini / Build the taxonomy according to the model */ |
| 147 | - $term = new $this->model_name( $wp_term, $this->meta_key, $cropped ); |
|
| 147 | + $term = new $this->model_name($wp_term, $this->meta_key, $cropped); |
|
| 148 | 148 | |
| 149 | 149 | return $term; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | public function show_model() { |
| 153 | - return _e( 'Try to get the model definition', 'term_ctr_mdl' ); |
|
| 153 | + return _e('Try to get the model definition', 'term_ctr_mdl'); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | /** |
@@ -161,15 +161,15 @@ discard block |
||
| 161 | 161 | * |
| 162 | 162 | * @return array La liste des taxinomies correspondantes aux paramètres / Taxonomies corresping to parameters |
| 163 | 163 | */ |
| 164 | - public function index( $args = array(), $cropped = false ) { |
|
| 164 | + public function index($args = array(), $cropped = false) { |
|
| 165 | 165 | $array_model = array(); |
| 166 | 166 | |
| 167 | - $term_final_args = array_merge( $args, array( 'hide_empty' => false, ) ); |
|
| 168 | - $array_term = get_terms( $this->taxonomy, $term_final_args ); |
|
| 167 | + $term_final_args = array_merge($args, array('hide_empty' => false,)); |
|
| 168 | + $array_term = get_terms($this->taxonomy, $term_final_args); |
|
| 169 | 169 | |
| 170 | - if( !empty( $array_term ) ) { |
|
| 171 | - foreach( $array_term as $key => $term ) { |
|
| 172 | - $array_model[$key] = new $this->model_name( $term, $this->meta_key, $cropped ); |
|
| 170 | + if (!empty($array_term)) { |
|
| 171 | + foreach ($array_term as $key => $term) { |
|
| 172 | + $array_model[$key] = new $this->model_name($term, $this->meta_key, $cropped); |
|
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | |
@@ -183,30 +183,30 @@ discard block |
||
| 183 | 183 | * |
| 184 | 184 | * @return array La liste des routes personnalisées ajoutées aux routes existantes / The personnalized routes added to existing |
| 185 | 185 | */ |
| 186 | - public function callback_register_route( $array_route ) { |
|
| 186 | + public function callback_register_route($array_route) { |
|
| 187 | 187 | /** Récupération de la définition du model pour l'élément / Get model structure for element */ |
| 188 | - $array_route['/' . $this->version . '/show_model/' . $this->base ] = array( |
|
| 189 | - array( array( $this, 'show_model' ), WP_JSON_Server::READABLE ) |
|
| 188 | + $array_route['/' . $this->version . '/show_model/' . $this->base] = array( |
|
| 189 | + array(array($this, 'show_model'), WP_JSON_Server::READABLE) |
|
| 190 | 190 | ); |
| 191 | 191 | |
| 192 | 192 | /** Récupération de la liste complète des éléments / Get all existing elements */ |
| 193 | - $array_route['/' . $this->version . '/get/' . $this->base ] = array( |
|
| 194 | - array( array( $this, 'index' ), WP_JSON_Server::READABLE | WP_JSON_Server::ACCEPT_JSON ) |
|
| 193 | + $array_route['/' . $this->version . '/get/' . $this->base] = array( |
|
| 194 | + array(array($this, 'index'), WP_JSON_Server::READABLE | WP_JSON_Server::ACCEPT_JSON) |
|
| 195 | 195 | ); |
| 196 | 196 | |
| 197 | 197 | /** Récupération d'un élément donné / Get a given element */ |
| 198 | 198 | $array_route['/' . $this->version . '/get/' . $this->base . '/(?P<id>\d+)'] = array( |
| 199 | - array( array( $this, 'show' ), WP_JSON_Server::READABLE | WP_JSON_Server::ACCEPT_JSON ) |
|
| 199 | + array(array($this, 'show'), WP_JSON_Server::READABLE | WP_JSON_Server::ACCEPT_JSON) |
|
| 200 | 200 | ); |
| 201 | 201 | |
| 202 | 202 | /** Mise à jour d'un élément / Update an element */ |
| 203 | 203 | $array_route['/' . $this->version . '/post/' . $this->base . ''] = array( |
| 204 | - array( array( $this, 'update' ), WP_JSON_Server::CREATABLE | WP_JSON_Server::ACCEPT_JSON ), |
|
| 204 | + array(array($this, 'update'), WP_JSON_Server::CREATABLE | WP_JSON_Server::ACCEPT_JSON), |
|
| 205 | 205 | ); |
| 206 | 206 | |
| 207 | 207 | /** Suppression d'un élément / Delete an element */ |
| 208 | 208 | $array_route['/' . $this->version . '/delete/' . $this->base . '/(?P<id>\d+)'] = array( |
| 209 | - array( array( $this, 'delete' ), WP_JSON_Server::DELETABLE | WP_JSON_Server::ACCEPT_JSON ), |
|
| 209 | + array(array($this, 'delete'), WP_JSON_Server::DELETABLE | WP_JSON_Server::ACCEPT_JSON), |
|
| 210 | 210 | ); |
| 211 | 211 | |
| 212 | 212 | return $array_route; |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | /** |
| 3 | 5 | * Fichier de gestion du modèle des taxinomies / File for term model management |
| 4 | 6 | * |
@@ -113,8 +115,7 @@ discard block |
||
| 113 | 115 | } |
| 114 | 116 | |
| 115 | 117 | return $object; |
| 116 | - } |
|
| 117 | - else { |
|
| 118 | + } else { |
|
| 118 | 119 | /** |
| 119 | 120 | * @todo return error when creation does not work |
| 120 | 121 | */ |
@@ -117,10 +117,7 @@ discard block |
||
| 117 | 117 | /** |
| 118 | 118 | * Get the sub categories of a given category |
| 119 | 119 | * |
| 120 | - * @param integer $parent_category The main category we want to have the sub categories for |
|
| 121 | - * @param array $instance The current instance of the widget, allows to get the different selected parameters |
|
| 122 | - * |
|
| 123 | - * @return mixed $widget_content The widget content build from option |
|
| 120 | + * @return string |
|
| 124 | 121 | */ |
| 125 | 122 | public static function category_tree_output($category_id = 0, $instance) { |
| 126 | 123 | global $category_has_sub_category; |
@@ -285,7 +282,7 @@ discard block |
||
| 285 | 282 | * @param object $category The category definition |
| 286 | 283 | * @param string $output_type The output type defined from plugin option |
| 287 | 284 | * |
| 288 | - * @return mixed $content Output the category list |
|
| 285 | + * @return string $content Output the category list |
|
| 289 | 286 | */ |
| 290 | 287 | public static function category_mini_output($category, $output_type = 'list'){ |
| 291 | 288 | $content = ''; |
@@ -420,7 +417,6 @@ discard block |
||
| 420 | 417 | * @see wp_get_attachment_image_src |
| 421 | 418 | * @param unknown_type $id |
| 422 | 419 | * @param unknown_type $size |
| 423 | - * @param unknown_type $attr |
|
| 424 | 420 | * @return (string or array) |
| 425 | 421 | */ |
| 426 | 422 | public static function get_the_category_thumbnail($id, $size = 'thumbnail', $icon = false) { |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | /** |
| 3 | 3 | * Products management method file |
| 4 | 4 | * |
@@ -10,8 +10,8 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | /* Check if file is include. No direct access possible with file url */ |
| 13 | -if ( !defined( 'WPSHOP_VERSION' ) ) { |
|
| 14 | - die( __('Access is not allowed by this way', 'wpshop') ); |
|
| 13 | +if (!defined('WPSHOP_VERSION')) { |
|
| 14 | + die(__('Access is not allowed by this way', 'wpshop')); |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | /** |
@@ -29,51 +29,51 @@ discard block |
||
| 29 | 29 | * @param string $product_search : recherche demand�e |
| 30 | 30 | * @return mixed |
| 31 | 31 | **/ |
| 32 | - public static function product_list_cats($formated=false, $product_search=null) { |
|
| 32 | + public static function product_list_cats($formated = false, $product_search = null) { |
|
| 33 | 33 | $where = array('hide_empty' => false); |
| 34 | - if(!empty($product_search)) |
|
| 34 | + if (!empty($product_search)) |
|
| 35 | 35 | $where = array_merge($where, array('name__like'=>$product_search)); |
| 36 | 36 | |
| 37 | 37 | $data = get_terms(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES, $where); |
| 38 | - $cats=array(); |
|
| 39 | - foreach($data as $d){ |
|
| 38 | + $cats = array(); |
|
| 39 | + foreach ($data as $d) { |
|
| 40 | 40 | $cats[$d->term_id] = $d->name; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | // Si le formatage est demand� |
| 44 | - $cats_string=''; |
|
| 45 | - if($formated) { |
|
| 46 | - if(!empty($cats)): |
|
| 47 | - foreach($cats as $key=>$value) { |
|
| 48 | - $cats_string.= ' |
|
| 49 | - <li><input type="checkbox" class="wpshop_shortcode_element wpshop_shortcode_element_categories" value="'.$key.'" id="'.WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES.'-'.$key.'" name="cats[]" /><label for="'.WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES.'-'.$key.'" > '.$value.'</label></li>'; |
|
| 44 | + $cats_string = ''; |
|
| 45 | + if ($formated) { |
|
| 46 | + if (!empty($cats)): |
|
| 47 | + foreach ($cats as $key=>$value) { |
|
| 48 | + $cats_string .= ' |
|
| 49 | + <li><input type="checkbox" class="wpshop_shortcode_element wpshop_shortcode_element_categories" value="'.$key . '" id="' . WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '-' . $key . '" name="cats[]" /><label for="' . WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '-' . $key . '" > ' . $value . '</label></li>'; |
|
| 50 | 50 | } |
| 51 | 51 | endif; |
| 52 | 52 | } |
| 53 | - return $formated?$cats_string:$cats; |
|
| 53 | + return $formated ? $cats_string : $cats; |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | 57 | * Call wordpress function that declare a new term type in order to define the product as wordpress term (taxonomy) |
| 58 | 58 | */ |
| 59 | - public static function create_product_categories(){ |
|
| 59 | + public static function create_product_categories() { |
|
| 60 | 60 | $options = get_option('wpshop_catalog_categories_option', null); |
| 61 | 61 | $slug = array( |
| 62 | 62 | 'slug' => '', |
| 63 | 63 | 'with_front' => true, |
| 64 | 64 | 'hierarchical' => true, |
| 65 | 65 | ); |
| 66 | - ( empty($options['wpshop_catalog_categories_slug']) || $options['wpshop_catalog_categories_slug'] == '/' ) ? $slug = false : $slug['slug'] = $options['wpshop_catalog_categories_slug']; |
|
| 66 | + (empty($options['wpshop_catalog_categories_slug']) || $options['wpshop_catalog_categories_slug'] == '/') ? $slug = false : $slug['slug'] = $options['wpshop_catalog_categories_slug']; |
|
| 67 | 67 | register_taxonomy(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES, array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT), array( |
| 68 | 68 | 'labels' => array( |
| 69 | 69 | 'name' => __('WPShop categories', 'wpshop'), |
| 70 | 70 | 'singular_name' => __('WPShop category', 'wpshop'), |
| 71 | 71 | 'add_new_item' => __('Add new WPShop category', 'wpshop'), |
| 72 | - 'add_new' => _x( 'Add new', 'admin menu: add new wpshop category', 'wpshop'), |
|
| 72 | + 'add_new' => _x('Add new', 'admin menu: add new wpshop category', 'wpshop'), |
|
| 73 | 73 | 'add_new_item' => __('Add new WPShop category', 'wpshop'), |
| 74 | 74 | 'edit_item' => __('Edit WPShop category', 'wpshop'), |
| 75 | 75 | 'new_item' => __('New WPShop category', 'wpshop'), |
| 76 | - 'view_item' => __('View WPShop category', 'wpshop' ), |
|
| 76 | + 'view_item' => __('View WPShop category', 'wpshop'), |
|
| 77 | 77 | 'search_items' => __('Search WPShop categories', 'wpshop'), |
| 78 | 78 | 'not_found' => __('No WPShop categories found', 'wpshop'), |
| 79 | 79 | 'not_found_in_trash' => __('No WPShop categories found in trash', 'wpshop'), |
@@ -94,19 +94,19 @@ discard block |
||
| 94 | 94 | * |
| 95 | 95 | * @return array $categories_list An array ordered by category with its children |
| 96 | 96 | */ |
| 97 | - public static function category_tree($category_id = 0){ |
|
| 97 | + public static function category_tree($category_id = 0) { |
|
| 98 | 98 | $categories_list = array(); |
| 99 | 99 | |
| 100 | 100 | $categories = get_terms(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES, 'hide_empty=0&parent=' . $category_id); |
| 101 | - if(count($categories) > 0){ |
|
| 102 | - foreach($categories as $category){ |
|
| 101 | + if (count($categories) > 0) { |
|
| 102 | + foreach ($categories as $category) { |
|
| 103 | 103 | /* If necessary un-comment this line in order to get the complete tree for the category */ |
| 104 | 104 | // $categories_list[$category->term_id]['children_tree'] = self::category_tree($category->term_id); |
| 105 | 105 | $categories_list[$category->term_id]['children_category'] = get_term_children($category->term_id, WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES); |
| 106 | 106 | |
| 107 | 107 | /* Get the product list for the category */ |
| 108 | 108 | $products = get_posts(array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES => $category->slug)); |
| 109 | - foreach($products as $product){ |
|
| 109 | + foreach ($products as $product) { |
|
| 110 | 110 | $categories_list[$category->term_id]['children_product'][] = $product->ID; |
| 111 | 111 | } |
| 112 | 112 | } |
@@ -127,10 +127,10 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | $widget_content = ''; |
| 129 | 129 | $category_tree = wpshop_categories::category_tree($category_id); |
| 130 | - if((!isset($instance['wpshop_widget_categories']) && !isset($instance['show_all_cat'])) || ($instance['show_all_cat'] == 'yes')){ |
|
| 130 | + if ((!isset($instance['wpshop_widget_categories']) && !isset($instance['show_all_cat'])) || ($instance['show_all_cat'] == 'yes')) { |
|
| 131 | 131 | $categories = get_terms(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES, 'hide_empty=0&parent=' . $category_id); |
| 132 | - if(count($categories) > 0){ |
|
| 133 | - foreach($categories as $category){ |
|
| 132 | + if (count($categories) > 0) { |
|
| 133 | + foreach ($categories as $category) { |
|
| 134 | 134 | ob_start(); |
| 135 | 135 | require(wpshop_display::get_template_file('categories-widget.tpl.php')); |
| 136 | 136 | $widget_content .= ob_get_contents(); |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | } |
| 139 | 139 | $category_has_sub_category = true; |
| 140 | 140 | } |
| 141 | - else{ |
|
| 141 | + else { |
|
| 142 | 142 | $category_has_sub_category = false; |
| 143 | 143 | } |
| 144 | 144 | } |
@@ -150,44 +150,44 @@ discard block |
||
| 150 | 150 | /** |
| 151 | 151 | * Add additionnal fields to the category edition form |
| 152 | 152 | */ |
| 153 | - public static function category_edit_fields(){ |
|
| 154 | - $category_id = (int) $_REQUEST["tag_ID"]; |
|
| 153 | + public static function category_edit_fields() { |
|
| 154 | + $category_id = (int)$_REQUEST["tag_ID"]; |
|
| 155 | 155 | $category_meta_information = get_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $category_id); |
| 156 | 156 | $tpl_component = array(); |
| 157 | 157 | wp_enqueue_media(); |
| 158 | - $category_thumbnail_preview = '<img src="' .WPSHOP_DEFAULT_CATEGORY_PICTURE. '" alt="No picture" class="category_thumbnail_preview" />'; |
|
| 158 | + $category_thumbnail_preview = '<img src="' . WPSHOP_DEFAULT_CATEGORY_PICTURE . '" alt="No picture" class="category_thumbnail_preview" />'; |
|
| 159 | 159 | /* Check if there is already a picture for the selected category */ |
| 160 | 160 | |
| 161 | - if ( !empty($category_meta_information['wpshop_category_picture']) ) { |
|
| 162 | - $image_post = wp_get_attachment_image( $category_meta_information['wpshop_category_picture'], 'thumbnail', false, array('class' => 'category_thumbnail_preview') ); |
|
| 163 | - $category_thumbnail_preview = ( !empty($image_post) ) ? $image_post : '<img src="' .WPSHOP_DEFAULT_CATEGORY_PICTURE. '" alt="No picture" class="category_thumbnail_preview" />'; |
|
| 161 | + if (!empty($category_meta_information['wpshop_category_picture'])) { |
|
| 162 | + $image_post = wp_get_attachment_image($category_meta_information['wpshop_category_picture'], 'thumbnail', false, array('class' => 'category_thumbnail_preview')); |
|
| 163 | + $category_thumbnail_preview = (!empty($image_post)) ? $image_post : '<img src="' . WPSHOP_DEFAULT_CATEGORY_PICTURE . '" alt="No picture" class="category_thumbnail_preview" />'; |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | |
| 167 | 167 | $tpl_component['CATEGORY_DELETE_PICTURE_BUTTON'] = ''; |
| 168 | - if( !empty($category_meta_information) && !empty($category_meta_information['wpshop_category_picture']) ) { |
|
| 169 | - $tpl_component['CATEGORY_DELETE_PICTURE_BUTTON'] = '<a href="#" role="button" id="wps-delete-category-picture" data-nonce="' . wp_create_nonce( 'wps_delete_picture_category' ) . '" class="wps-bton-second-mini-rounded">' .__( 'Delete the category picture', 'wpshop' ). '</a> '; |
|
| 168 | + if (!empty($category_meta_information) && !empty($category_meta_information['wpshop_category_picture'])) { |
|
| 169 | + $tpl_component['CATEGORY_DELETE_PICTURE_BUTTON'] = '<a href="#" role="button" id="wps-delete-category-picture" data-nonce="' . wp_create_nonce('wps_delete_picture_category') . '" class="wps-bton-second-mini-rounded">' . __('Delete the category picture', 'wpshop') . '</a> '; |
|
| 170 | 170 | } |
| 171 | - $tpl_component['CATEGORY_PICTURE_ID'] = ( ( !empty($category_meta_information['wpshop_category_picture']) ) ? $category_meta_information['wpshop_category_picture'] : '' ); |
|
| 171 | + $tpl_component['CATEGORY_PICTURE_ID'] = ((!empty($category_meta_information['wpshop_category_picture'])) ? $category_meta_information['wpshop_category_picture'] : ''); |
|
| 172 | 172 | |
| 173 | 173 | $tpl_component['CATEGORY_THUMBNAIL_PREVIEW'] = $category_thumbnail_preview; |
| 174 | - if(isset($category_id)){ |
|
| 174 | + if (isset($category_id)) { |
|
| 175 | 175 | $tpl_component['CATEGORY_TAG_ID'] = $category_id; |
| 176 | 176 | $tpl_component['CATEGORY_FILTERABLE_ATTRIBUTES'] = ''; |
| 177 | - $wpshop_category_products = wpshop_categories::get_product_of_category( $category_id ); |
|
| 177 | + $wpshop_category_products = wpshop_categories::get_product_of_category($category_id); |
|
| 178 | 178 | $filterable_attributes_list = array(); |
| 179 | - foreach ( $wpshop_category_products as $wpshop_category_product ) { |
|
| 179 | + foreach ($wpshop_category_products as $wpshop_category_product) { |
|
| 180 | 180 | $elementId = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT); |
| 181 | - if ( !empty($elementId) ) { |
|
| 181 | + if (!empty($elementId)) { |
|
| 182 | 182 | $product_attributes = wpshop_attributes::get_attribute_list_for_item($elementId, $wpshop_category_product); |
| 183 | - if ( !empty($product_attributes) ) { |
|
| 184 | - foreach ( $product_attributes as $key => $product_attribute ) { |
|
| 185 | - if ( !empty($product_attribute) && !empty($product_attribute->is_filterable) && strtolower(__($product_attribute->is_filterable, 'wpshop')) == strtolower(__('Yes', 'wpshop')) ) { |
|
| 186 | - if ( !array_key_exists($product_attribute->attribute_id, $filterable_attributes_list) ) { |
|
| 183 | + if (!empty($product_attributes)) { |
|
| 184 | + foreach ($product_attributes as $key => $product_attribute) { |
|
| 185 | + if (!empty($product_attribute) && !empty($product_attribute->is_filterable) && strtolower(__($product_attribute->is_filterable, 'wpshop')) == strtolower(__('Yes', 'wpshop'))) { |
|
| 186 | + if (!array_key_exists($product_attribute->attribute_id, $filterable_attributes_list)) { |
|
| 187 | 187 | $filterable_attributes_list[$product_attribute->attribute_id] = $product_attribute; |
| 188 | - $sub_tpl_component['CATEGORY_FILTERABLE_ATTRIBUTE_ID'] = $product_attribute->attribute_id; |
|
| 189 | - $sub_tpl_component['CATEGORY_FILTERABLE_ATTRIBUTE_NAME'] = __($product_attribute->frontend_label, 'wpshop'); |
|
| 190 | - if ( !empty($category_meta_information) && !empty($category_meta_information['wpshop_category_filterable_attributes']) && array_key_exists($product_attribute->attribute_id, $category_meta_information['wpshop_category_filterable_attributes']) ) { |
|
| 188 | + $sub_tpl_component['CATEGORY_FILTERABLE_ATTRIBUTE_ID'] = $product_attribute->attribute_id; |
|
| 189 | + $sub_tpl_component['CATEGORY_FILTERABLE_ATTRIBUTE_NAME'] = __($product_attribute->frontend_label, 'wpshop'); |
|
| 190 | + if (!empty($category_meta_information) && !empty($category_meta_information['wpshop_category_filterable_attributes']) && array_key_exists($product_attribute->attribute_id, $category_meta_information['wpshop_category_filterable_attributes'])) { |
|
| 191 | 191 | $sub_tpl_component['CATEGORY_FILTERABLE_ATTRIBUTE_CHECKED'] = 'checked="checked"'; |
| 192 | 192 | } |
| 193 | 193 | else { |
@@ -218,20 +218,20 @@ discard block |
||
| 218 | 218 | * |
| 219 | 219 | * @return void |
| 220 | 220 | */ |
| 221 | - public static function category_fields_saver($category_id, $tt_id){ |
|
| 221 | + public static function category_fields_saver($category_id, $tt_id) { |
|
| 222 | 222 | global $wpdb; |
| 223 | 223 | $category_meta = array(); |
| 224 | - $category_option = get_option( WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $category_id); |
|
| 224 | + $category_option = get_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $category_id); |
|
| 225 | 225 | |
| 226 | - $wps_category_picture_id = !empty($_POST['wps_category_picture_id']) ? (int) $_POST['wps_category_picture_id'] : null; |
|
| 227 | - $filterable_attribute_for_category = ( !empty($_POST['filterable_attribute_for_category']) && is_array($_POST['filterable_attribute_for_category']) ) ? (array) $_POST['filterable_attribute_for_category'] : null; |
|
| 226 | + $wps_category_picture_id = !empty($_POST['wps_category_picture_id']) ? (int)$_POST['wps_category_picture_id'] : null; |
|
| 227 | + $filterable_attribute_for_category = (!empty($_POST['filterable_attribute_for_category']) && is_array($_POST['filterable_attribute_for_category'])) ? (array)$_POST['filterable_attribute_for_category'] : null; |
|
| 228 | 228 | |
| 229 | - if ( isset( $wps_category_picture_id ) ) { |
|
| 230 | - $attach_id = intval( $wps_category_picture_id ); |
|
| 229 | + if (isset($wps_category_picture_id)) { |
|
| 230 | + $attach_id = intval($wps_category_picture_id); |
|
| 231 | 231 | $category_option['wpshop_category_picture'] = $attach_id; |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - if ( isset( $filterable_attribute_for_category ) ) { |
|
| 234 | + if (isset($filterable_attribute_for_category)) { |
|
| 235 | 235 | $category_option['wpshop_category_filterable_attributes'] = $filterable_attribute_for_category; |
| 236 | 236 | } |
| 237 | 237 | else { |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | |
| 242 | 242 | /** Update filter values **/ |
| 243 | 243 | $wpshop_filter_search = new wps_filter_search(); |
| 244 | - $wpshop_filter_search->stock_values_for_attribute( array($category_id) ); |
|
| 244 | + $wpshop_filter_search->stock_values_for_attribute(array($category_id)); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | /** |
@@ -251,15 +251,15 @@ discard block |
||
| 251 | 251 | * |
| 252 | 252 | * @return array $columns The new array with additionnal colu |
| 253 | 253 | */ |
| 254 | - public static function category_manage_columns($columns){ |
|
| 255 | - unset( $columns["cb"] ); |
|
| 254 | + public static function category_manage_columns($columns) { |
|
| 255 | + unset($columns["cb"]); |
|
| 256 | 256 | |
| 257 | 257 | $custom_array = array( |
| 258 | 258 | 'cb' => '<input type="checkbox" />', |
| 259 | 259 | 'wpshop_category_thumbnail' => __('Thumbnail', 'wpshop') |
| 260 | 260 | ); |
| 261 | 261 | |
| 262 | - $columns = array_merge( $custom_array, $columns ); |
|
| 262 | + $columns = array_merge($custom_array, $columns); |
|
| 263 | 263 | |
| 264 | 264 | return $columns; |
| 265 | 265 | } |
@@ -267,13 +267,13 @@ discard block |
||
| 267 | 267 | /** |
| 268 | 268 | * Define the content of extra columns to add to categories listing interface |
| 269 | 269 | */ |
| 270 | - public static function category_manage_columns_content($string, $column_name, $category_id){ |
|
| 270 | + public static function category_manage_columns_content($string, $column_name, $category_id) { |
|
| 271 | 271 | $category_meta_information = get_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $category_id); |
| 272 | - $category_thumbnail_preview = '<img src="' .WPSHOP_DEFAULT_CATEGORY_PICTURE. '" alt="No picture" class="category_thumbnail_preview" />'; |
|
| 272 | + $category_thumbnail_preview = '<img src="' . WPSHOP_DEFAULT_CATEGORY_PICTURE . '" alt="No picture" class="category_thumbnail_preview" />'; |
|
| 273 | 273 | /* Check if there is already a picture for the selected category */ |
| 274 | - if ( !empty($category_meta_information['wpshop_category_picture']) ) { |
|
| 275 | - $image_post = wp_get_attachment_image( $category_meta_information['wpshop_category_picture'], 'thumbnail', false, array('class' => 'category_thumbnail_preview') ); |
|
| 276 | - $category_thumbnail_preview = ( !empty($image_post) ) ? $image_post : '<img src="' .WPSHOP_DEFAULT_CATEGORY_PICTURE. '" alt="No picture" class="category_thumbnail_preview" />'; |
|
| 274 | + if (!empty($category_meta_information['wpshop_category_picture'])) { |
|
| 275 | + $image_post = wp_get_attachment_image($category_meta_information['wpshop_category_picture'], 'thumbnail', false, array('class' => 'category_thumbnail_preview')); |
|
| 276 | + $category_thumbnail_preview = (!empty($image_post)) ? $image_post : '<img src="' . WPSHOP_DEFAULT_CATEGORY_PICTURE . '" alt="No picture" class="category_thumbnail_preview" />'; |
|
| 277 | 277 | } |
| 278 | 278 | $category = get_term_by('id', $category_id, WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES); |
| 279 | 279 | $name = $category->name; |
@@ -291,21 +291,21 @@ discard block |
||
| 291 | 291 | * |
| 292 | 292 | * @return mixed $content Output the category list |
| 293 | 293 | */ |
| 294 | - public static function category_mini_output($category, $output_type = 'list'){ |
|
| 294 | + public static function category_mini_output($category, $output_type = 'list') { |
|
| 295 | 295 | $content = ''; |
| 296 | 296 | /* Get the different informations for output */ |
| 297 | - $category_meta_information = ( !empty($category) && !empty($category->term_id) ) ? get_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $category->term_id) : ''; |
|
| 298 | - $categoryThumbnail = '<img src="' .WPSHOP_DEFAULT_CATEGORY_PICTURE. '" alt="No picture" class="wps-category-thumbnail" />'; |
|
| 297 | + $category_meta_information = (!empty($category) && !empty($category->term_id)) ? get_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $category->term_id) : ''; |
|
| 298 | + $categoryThumbnail = '<img src="' . WPSHOP_DEFAULT_CATEGORY_PICTURE . '" alt="No picture" class="wps-category-thumbnail" />'; |
|
| 299 | 299 | /* Check if there is already a picture for the selected category */ |
| 300 | - if ( !empty($category_meta_information['wpshop_category_picture']) ) { |
|
| 301 | - $image_post = wp_get_attachment_image( $category_meta_information['wpshop_category_picture'], 'wps-categorie-display', false, array('class' => 'wps-category-thumbnail') ); |
|
| 302 | - $categoryThumbnail = ( !empty($image_post) ) ? $image_post : '<img src="' .WPSHOP_DEFAULT_CATEGORY_PICTURE. '" alt="No picture" class="wps-category-thumbnail" />'; |
|
| 300 | + if (!empty($category_meta_information['wpshop_category_picture'])) { |
|
| 301 | + $image_post = wp_get_attachment_image($category_meta_information['wpshop_category_picture'], 'wps-categorie-display', false, array('class' => 'wps-category-thumbnail')); |
|
| 302 | + $categoryThumbnail = (!empty($image_post)) ? $image_post : '<img src="' . WPSHOP_DEFAULT_CATEGORY_PICTURE . '" alt="No picture" class="wps-category-thumbnail" />'; |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | |
| 306 | - $category_title = ( !empty($category) && !empty($category->name) ) ? $category->name : ''; |
|
| 307 | - $category_more_informations = ( !empty($category) && !empty($category->description) ) ? wp_trim_words( $category->description, 30, ' [...]' ) : ''; |
|
| 308 | - $category_link = ( !empty($category) && !empty($category->term_id) ) ? get_term_link((int)$category->term_id , WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES) : ''; |
|
| 306 | + $category_title = (!empty($category) && !empty($category->name)) ? $category->name : ''; |
|
| 307 | + $category_more_informations = (!empty($category) && !empty($category->description)) ? wp_trim_words($category->description, 30, ' [...]') : ''; |
|
| 308 | + $category_link = (!empty($category) && !empty($category->term_id)) ? get_term_link((int)$category->term_id, WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES) : ''; |
|
| 309 | 309 | |
| 310 | 310 | // $item_width = null; |
| 311 | 311 | // /* Make some treatment in case we are in grid mode */ |
@@ -326,14 +326,14 @@ discard block |
||
| 326 | 326 | $tpl_component['CATEGORY_TITLE'] = $category_title; |
| 327 | 327 | $tpl_component['CATEGORY_DESCRIPTION'] = $category_more_informations; |
| 328 | 328 | //$tpl_component['ITEM_WIDTH'] = $item_width; |
| 329 | - $tpl_component['CATEGORY_ID'] = ( !empty($category) && !empty($category->term_id) ) ? $category->term_id : ''; |
|
| 329 | + $tpl_component['CATEGORY_ID'] = (!empty($category) && !empty($category->term_id)) ? $category->term_id : ''; |
|
| 330 | 330 | $tpl_component['CATEGORY_DISPLAY_TYPE'] = $output_type; |
| 331 | 331 | |
| 332 | 332 | /* |
| 333 | 333 | * Build template |
| 334 | 334 | */ |
| 335 | 335 | $tpl_way_to_take = wpshop_display::check_way_for_template($template_part); |
| 336 | - if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) { |
|
| 336 | + if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) { |
|
| 337 | 337 | /* Include the old way template part */ |
| 338 | 338 | |
| 339 | 339 | ob_start(); |
@@ -358,22 +358,22 @@ discard block |
||
| 358 | 358 | public static function wpshop_category_func($atts) { |
| 359 | 359 | global $wpdb; |
| 360 | 360 | $string = ''; |
| 361 | - if ( !empty($atts['cid']) ) { |
|
| 362 | - $atts['type'] = (!empty($atts['type']) && in_array($atts['type'],array('grid','list'))) ? $atts['type'] : 'grid'; |
|
| 361 | + if (!empty($atts['cid'])) { |
|
| 362 | + $atts['type'] = (!empty($atts['type']) && in_array($atts['type'], array('grid', 'list'))) ? $atts['type'] : 'grid'; |
|
| 363 | 363 | |
| 364 | 364 | $cat_list = explode(',', $atts['cid']); |
| 365 | 365 | |
| 366 | - if ( (count($cat_list) > 1) || ( !empty($atts['display']) && ($atts['display'] == 'only_cat') ) ) { |
|
| 367 | - if( count($cat_list) == 1) { |
|
| 366 | + if ((count($cat_list) > 1) || (!empty($atts['display']) && ($atts['display'] == 'only_cat'))) { |
|
| 367 | + if (count($cat_list) == 1) { |
|
| 368 | 368 | $args = array('taxonomy' => WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES, 'parent' => $cat_list[0]); |
| 369 | - $categories = get_terms( $args ); |
|
| 370 | - foreach($categories as $category) { |
|
| 369 | + $categories = get_terms($args); |
|
| 370 | + foreach ($categories as $category) { |
|
| 371 | 371 | $cat_list[] = $category->term_id; |
| 372 | 372 | } |
| 373 | 373 | } |
| 374 | 374 | $string .= ' |
| 375 | 375 | <div class="wpshop_categories_' . $atts['type'] . '" >'; |
| 376 | - foreach( $cat_list as $cat_id ){ |
|
| 376 | + foreach ($cat_list as $cat_id) { |
|
| 377 | 377 | $sub_category_def = get_term($cat_id, WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES); |
| 378 | 378 | $string .= wpshop_categories::category_mini_output($sub_category_def, $atts['type']); |
| 379 | 379 | } |
@@ -383,16 +383,16 @@ discard block |
||
| 383 | 383 | else { |
| 384 | 384 | $sub_category_def = get_term($atts['cid'], WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES); |
| 385 | 385 | |
| 386 | - if ( empty($atts['display']) || ($atts['display'] != 'only_products') ){ |
|
| 386 | + if (empty($atts['display']) || ($atts['display'] != 'only_products')) { |
|
| 387 | 387 | $string .= wpshop_categories::category_mini_output($sub_category_def, $atts['type']); |
| 388 | 388 | $string .= ' |
| 389 | 389 | <div class="category_product_' . $atts['type'] . '" > |
| 390 | - <h2 class="category_content_part_title" >'.__('Category\'s product list', 'wpshop').'</h2>'; |
|
| 390 | + <h2 class="category_content_part_title" >'.__('Category\'s product list', 'wpshop') . '</h2>'; |
|
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | $string .= wpshop_products::wpshop_products_func($atts); |
| 394 | 394 | |
| 395 | - if ( empty($atts['display']) || ($atts['display'] != 'only_products') ){ |
|
| 395 | + if (empty($atts['display']) || ($atts['display'] != 'only_products')) { |
|
| 396 | 396 | $string .= '</div>'; |
| 397 | 397 | } |
| 398 | 398 | } |
@@ -404,14 +404,14 @@ discard block |
||
| 404 | 404 | return do_shortcode($string); |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | - public static function get_product_of_category( $category_id ) { |
|
| 407 | + public static function get_product_of_category($category_id) { |
|
| 408 | 408 | $product_id_list = array(); |
| 409 | - if ( !empty($category_id) ) { |
|
| 409 | + if (!empty($category_id)) { |
|
| 410 | 410 | global $wpdb; |
| 411 | 411 | $query = $wpdb->prepare("SELECT T.* FROM " . $wpdb->term_relationships . " AS T INNER JOIN " . $wpdb->posts . " AS P ON ((P.ID = T.object_id) AND (P.post_status = %s)) WHERE T.term_taxonomy_id = %d ", 'publish', $category_id); |
| 412 | 412 | $relationships = $wpdb->get_results($query); |
| 413 | - if ( !empty($relationships) ) { |
|
| 414 | - foreach ( $relationships as $relationship ) { |
|
| 413 | + if (!empty($relationships)) { |
|
| 414 | + foreach ($relationships as $relationship) { |
|
| 415 | 415 | $product_id_list[] = $relationship->object_id; |
| 416 | 416 | } |
| 417 | 417 | } |
@@ -436,10 +436,10 @@ discard block |
||
| 436 | 436 | */ |
| 437 | 437 | public static function get_the_category_thumbnail($id, $size = 'thumbnail', $icon = false) { |
| 438 | 438 | /** Get the attachment/post ID */ |
| 439 | - $array_option_category = get_option('wpshop_product_category_' . $id); |
|
| 439 | + $array_option_category = get_option('wpshop_product_category_' . $id); |
|
| 440 | 440 | |
| 441 | 441 | /** If not attachment/post ID in the category, return "No thumbnail in the category" */ |
| 442 | - if(is_array($array_option_category) && empty($array_option_category['wpshop_category_picture'])) |
|
| 442 | + if (is_array($array_option_category) && empty($array_option_category['wpshop_category_picture'])) |
|
| 443 | 443 | return __('No thumbnail in the category', 'wpshop'); |
| 444 | 444 | |
| 445 | 445 | /** Set attachment/post ID in $id_picture */ |
@@ -451,7 +451,7 @@ discard block |
||
| 451 | 451 | */ |
| 452 | 452 | $post_thumbnail = wp_get_attachment_image_src($id_picture, $size, $icon); |
| 453 | 453 | |
| 454 | - if(!$post_thumbnail) |
|
| 454 | + if (!$post_thumbnail) |
|
| 455 | 455 | return __('No thumbnail in this post', 'wpshop'); |
| 456 | 456 | |
| 457 | 457 | return $post_thumbnail; |
@@ -24,11 +24,11 @@ discard block |
||
| 24 | 24 | class wpshop_categories |
| 25 | 25 | { |
| 26 | 26 | /** |
| 27 | - * Retourne une liste de cat�gorie |
|
| 28 | - * @param boolean $formated : formatage du r�sultat oui/non |
|
| 29 | - * @param string $product_search : recherche demand�e |
|
| 30 | - * @return mixed |
|
| 31 | - **/ |
|
| 27 | + * Retourne une liste de cat�gorie |
|
| 28 | + * @param boolean $formated : formatage du r�sultat oui/non |
|
| 29 | + * @param string $product_search : recherche demand�e |
|
| 30 | + * @return mixed |
|
| 31 | + **/ |
|
| 32 | 32 | public static function product_list_cats($formated=false, $product_search=null) { |
| 33 | 33 | $where = array('hide_empty' => false); |
| 34 | 34 | if(!empty($product_search)) |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | - * Call wordpress function that declare a new term type in order to define the product as wordpress term (taxonomy) |
|
| 58 | - */ |
|
| 57 | + * Call wordpress function that declare a new term type in order to define the product as wordpress term (taxonomy) |
|
| 58 | + */ |
|
| 59 | 59 | public static function create_product_categories(){ |
| 60 | 60 | $options = get_option('wpshop_catalog_categories_option', null); |
| 61 | 61 | $slug = array( |
@@ -88,12 +88,12 @@ discard block |
||
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
| 91 | - * Build a complete tree with the categories. Contains the complete tree for a given category and a children list for easy checking |
|
| 92 | - * |
|
| 93 | - * @param integer $category_id The category identifier we want to get the tree element for |
|
| 94 | - * |
|
| 95 | - * @return array $categories_list An array ordered by category with its children |
|
| 96 | - */ |
|
| 91 | + * Build a complete tree with the categories. Contains the complete tree for a given category and a children list for easy checking |
|
| 92 | + * |
|
| 93 | + * @param integer $category_id The category identifier we want to get the tree element for |
|
| 94 | + * |
|
| 95 | + * @return array $categories_list An array ordered by category with its children |
|
| 96 | + */ |
|
| 97 | 97 | public static function category_tree($category_id = 0){ |
| 98 | 98 | $categories_list = array(); |
| 99 | 99 | |
@@ -115,13 +115,13 @@ discard block |
||
| 115 | 115 | return $categories_list; |
| 116 | 116 | } |
| 117 | 117 | /** |
| 118 | - * Get the sub categories of a given category |
|
| 119 | - * |
|
| 120 | - * @param integer $parent_category The main category we want to have the sub categories for |
|
| 121 | - * @param array $instance The current instance of the widget, allows to get the different selected parameters |
|
| 122 | - * |
|
| 123 | - * @return mixed $widget_content The widget content build from option |
|
| 124 | - */ |
|
| 118 | + * Get the sub categories of a given category |
|
| 119 | + * |
|
| 120 | + * @param integer $parent_category The main category we want to have the sub categories for |
|
| 121 | + * @param array $instance The current instance of the widget, allows to get the different selected parameters |
|
| 122 | + * |
|
| 123 | + * @return mixed $widget_content The widget content build from option |
|
| 124 | + */ |
|
| 125 | 125 | public static function category_tree_output($category_id = 0, $instance) { |
| 126 | 126 | global $category_has_sub_category; |
| 127 | 127 | |
@@ -148,8 +148,8 @@ discard block |
||
| 148 | 148 | |
| 149 | 149 | |
| 150 | 150 | /** |
| 151 | - * Add additionnal fields to the category edition form |
|
| 152 | - */ |
|
| 151 | + * Add additionnal fields to the category edition form |
|
| 152 | + */ |
|
| 153 | 153 | public static function category_edit_fields(){ |
| 154 | 154 | $category_id = (int) $_REQUEST["tag_ID"]; |
| 155 | 155 | $category_meta_information = get_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $category_id); |
@@ -211,13 +211,13 @@ discard block |
||
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | /** |
| 214 | - * Save the different extra fields added for the plugin |
|
| 215 | - * |
|
| 216 | - * @param integer $category_id The category identifier we want to save extra fields for |
|
| 217 | - * @param mixed $tt_id |
|
| 218 | - * |
|
| 219 | - * @return void |
|
| 220 | - */ |
|
| 214 | + * Save the different extra fields added for the plugin |
|
| 215 | + * |
|
| 216 | + * @param integer $category_id The category identifier we want to save extra fields for |
|
| 217 | + * @param mixed $tt_id |
|
| 218 | + * |
|
| 219 | + * @return void |
|
| 220 | + */ |
|
| 221 | 221 | public static function category_fields_saver($category_id, $tt_id){ |
| 222 | 222 | global $wpdb; |
| 223 | 223 | $category_meta = array(); |
@@ -245,28 +245,28 @@ discard block |
||
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | /** |
| 248 | - * Add extra column to categories listing interface |
|
| 249 | - * |
|
| 250 | - * @param array $columns Actual columns to add extra columns to |
|
| 251 | - * |
|
| 252 | - * @return array $columns The new array with additionnal colu |
|
| 253 | - */ |
|
| 248 | + * Add extra column to categories listing interface |
|
| 249 | + * |
|
| 250 | + * @param array $columns Actual columns to add extra columns to |
|
| 251 | + * |
|
| 252 | + * @return array $columns The new array with additionnal colu |
|
| 253 | + */ |
|
| 254 | 254 | public static function category_manage_columns($columns){ |
| 255 | - unset( $columns["cb"] ); |
|
| 255 | + unset( $columns["cb"] ); |
|
| 256 | 256 | |
| 257 | - $custom_array = array( |
|
| 257 | + $custom_array = array( |
|
| 258 | 258 | 'cb' => '<input type="checkbox" />', |
| 259 | 259 | 'wpshop_category_thumbnail' => __('Thumbnail', 'wpshop') |
| 260 | - ); |
|
| 260 | + ); |
|
| 261 | 261 | |
| 262 | - $columns = array_merge( $custom_array, $columns ); |
|
| 262 | + $columns = array_merge( $custom_array, $columns ); |
|
| 263 | 263 | |
| 264 | - return $columns; |
|
| 264 | + return $columns; |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | /** |
| 268 | - * Define the content of extra columns to add to categories listing interface |
|
| 269 | - */ |
|
| 268 | + * Define the content of extra columns to add to categories listing interface |
|
| 269 | + */ |
|
| 270 | 270 | public static function category_manage_columns_content($string, $column_name, $category_id){ |
| 271 | 271 | $category_meta_information = get_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $category_id); |
| 272 | 272 | $category_thumbnail_preview = '<img src="' .WPSHOP_DEFAULT_CATEGORY_PICTURE. '" alt="No picture" class="category_thumbnail_preview" />'; |
@@ -279,18 +279,18 @@ discard block |
||
| 279 | 279 | $name = $category->name; |
| 280 | 280 | |
| 281 | 281 | $image = $category_thumbnail_preview; |
| 282 | - return $image; |
|
| 282 | + return $image; |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | |
| 286 | 286 | /** |
| 287 | - * Display a category in a list |
|
| 288 | - * |
|
| 289 | - * @param object $category The category definition |
|
| 290 | - * @param string $output_type The output type defined from plugin option |
|
| 291 | - * |
|
| 292 | - * @return mixed $content Output the category list |
|
| 293 | - */ |
|
| 287 | + * Display a category in a list |
|
| 288 | + * |
|
| 289 | + * @param object $category The category definition |
|
| 290 | + * @param string $output_type The output type defined from plugin option |
|
| 291 | + * |
|
| 292 | + * @return mixed $content Output the category list |
|
| 293 | + */ |
|
| 294 | 294 | public static function category_mini_output($category, $output_type = 'list'){ |
| 295 | 295 | $content = ''; |
| 296 | 296 | /* Get the different informations for output */ |
@@ -351,10 +351,10 @@ discard block |
||
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | /** |
| 354 | - * Traduit le shortcode et affiche une cat�gorie |
|
| 355 | - * @param array $atts : tableau de param�tre du shortcode |
|
| 356 | - * @return mixed |
|
| 357 | - **/ |
|
| 354 | + * Traduit le shortcode et affiche une cat�gorie |
|
| 355 | + * @param array $atts : tableau de param�tre du shortcode |
|
| 356 | + * @return mixed |
|
| 357 | + **/ |
|
| 358 | 358 | public static function wpshop_category_func($atts) { |
| 359 | 359 | global $wpdb; |
| 360 | 360 | $string = ''; |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | /** |
| 3 | 5 | * Products management method file |
| 4 | 6 | * |
@@ -31,8 +33,9 @@ discard block |
||
| 31 | 33 | **/ |
| 32 | 34 | public static function product_list_cats($formated=false, $product_search=null) { |
| 33 | 35 | $where = array('hide_empty' => false); |
| 34 | - if(!empty($product_search)) |
|
| 35 | - $where = array_merge($where, array('name__like'=>$product_search)); |
|
| 36 | + if(!empty($product_search)) { |
|
| 37 | + $where = array_merge($where, array('name__like'=>$product_search)); |
|
| 38 | + } |
|
| 36 | 39 | |
| 37 | 40 | $data = get_terms(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES, $where); |
| 38 | 41 | $cats=array(); |
@@ -137,8 +140,7 @@ discard block |
||
| 137 | 140 | ob_end_clean(); |
| 138 | 141 | } |
| 139 | 142 | $category_has_sub_category = true; |
| 140 | - } |
|
| 141 | - else{ |
|
| 143 | + } else{ |
|
| 142 | 144 | $category_has_sub_category = false; |
| 143 | 145 | } |
| 144 | 146 | } |
@@ -189,8 +191,7 @@ discard block |
||
| 189 | 191 | $sub_tpl_component['CATEGORY_FILTERABLE_ATTRIBUTE_NAME'] = __($product_attribute->frontend_label, 'wpshop'); |
| 190 | 192 | if ( !empty($category_meta_information) && !empty($category_meta_information['wpshop_category_filterable_attributes']) && array_key_exists($product_attribute->attribute_id, $category_meta_information['wpshop_category_filterable_attributes']) ) { |
| 191 | 193 | $sub_tpl_component['CATEGORY_FILTERABLE_ATTRIBUTE_CHECKED'] = 'checked="checked"'; |
| 192 | - } |
|
| 193 | - else { |
|
| 194 | + } else { |
|
| 194 | 195 | $sub_tpl_component['CATEGORY_FILTERABLE_ATTRIBUTE_CHECKED'] = ''; |
| 195 | 196 | } |
| 196 | 197 | |
@@ -202,8 +203,7 @@ discard block |
||
| 202 | 203 | } |
| 203 | 204 | } |
| 204 | 205 | } |
| 205 | - } |
|
| 206 | - else { |
|
| 206 | + } else { |
|
| 207 | 207 | $tpl_component['CATEGORY_TAG_ID'] = 1; |
| 208 | 208 | } |
| 209 | 209 | $output = wpshop_display::display_template_element('wpshop_category_edit_interface_admin', $tpl_component, array(), 'admin'); |
@@ -233,8 +233,7 @@ discard block |
||
| 233 | 233 | |
| 234 | 234 | if ( isset( $filterable_attribute_for_category ) ) { |
| 235 | 235 | $category_option['wpshop_category_filterable_attributes'] = $filterable_attribute_for_category; |
| 236 | - } |
|
| 237 | - else { |
|
| 236 | + } else { |
|
| 238 | 237 | $category_option['wpshop_category_filterable_attributes'] = array(); |
| 239 | 238 | } |
| 240 | 239 | update_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $category_id, $category_option); |
@@ -340,8 +339,7 @@ discard block |
||
| 340 | 339 | require(wpshop_display::get_template_file($tpl_way_to_take[1])); |
| 341 | 340 | $content = ob_get_contents(); |
| 342 | 341 | ob_end_clean(); |
| 343 | - } |
|
| 344 | - else { |
|
| 342 | + } else { |
|
| 345 | 343 | //echo $template_part.'-'.$tpl_component.'<br>'; |
| 346 | 344 | $content = wpshop_display::display_template_element($template_part, $tpl_component); |
| 347 | 345 | } |
@@ -379,8 +377,7 @@ discard block |
||
| 379 | 377 | } |
| 380 | 378 | $string .= ' |
| 381 | 379 | </div>'; |
| 382 | - } |
|
| 383 | - else { |
|
| 380 | + } else { |
|
| 384 | 381 | $sub_category_def = get_term($atts['cid'], WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES); |
| 385 | 382 | |
| 386 | 383 | if ( empty($atts['display']) || ($atts['display'] != 'only_products') ){ |
@@ -396,8 +393,7 @@ discard block |
||
| 396 | 393 | $string .= '</div>'; |
| 397 | 394 | } |
| 398 | 395 | } |
| 399 | - } |
|
| 400 | - else { |
|
| 396 | + } else { |
|
| 401 | 397 | $string .= __('No categories found for display', 'wpshop'); |
| 402 | 398 | } |
| 403 | 399 | |
@@ -439,8 +435,9 @@ discard block |
||
| 439 | 435 | $array_option_category = get_option('wpshop_product_category_' . $id); |
| 440 | 436 | |
| 441 | 437 | /** If not attachment/post ID in the category, return "No thumbnail in the category" */ |
| 442 | - if(is_array($array_option_category) && empty($array_option_category['wpshop_category_picture'])) |
|
| 443 | - return __('No thumbnail in the category', 'wpshop'); |
|
| 438 | + if(is_array($array_option_category) && empty($array_option_category['wpshop_category_picture'])) { |
|
| 439 | + return __('No thumbnail in the category', 'wpshop'); |
|
| 440 | + } |
|
| 444 | 441 | |
| 445 | 442 | /** Set attachment/post ID in $id_picture */ |
| 446 | 443 | $id_picture = $array_option_category['wpshop_category_picture']; |
@@ -451,8 +448,9 @@ discard block |
||
| 451 | 448 | */ |
| 452 | 449 | $post_thumbnail = wp_get_attachment_image_src($id_picture, $size, $icon); |
| 453 | 450 | |
| 454 | - if(!$post_thumbnail) |
|
| 455 | - return __('No thumbnail in this post', 'wpshop'); |
|
| 451 | + if(!$post_thumbnail) { |
|
| 452 | + return __('No thumbnail in this post', 'wpshop'); |
|
| 453 | + } |
|
| 456 | 454 | |
| 457 | 455 | return $post_thumbnail; |
| 458 | 456 | } |
@@ -120,6 +120,7 @@ discard block |
||
| 120 | 120 | * Save a new attribute in database |
| 121 | 121 | * |
| 122 | 122 | * @param array $informationsToSet An array with the different information we want to set |
| 123 | + * @param string $dataBaseTable |
|
| 123 | 124 | * |
| 124 | 125 | * @return string $requestResponse A message that allows to know if the creation has been done correctly or not |
| 125 | 126 | */ |
@@ -141,6 +142,7 @@ discard block |
||
| 141 | 142 | * Update an existing attribute in database |
| 142 | 143 | * |
| 143 | 144 | * @param array $informationsToSet An array with the different information we want to set |
| 145 | + * @param string $dataBaseTable |
|
| 144 | 146 | * |
| 145 | 147 | * @return string $requestResponse A message that allows to know if the update has been done correctly or not |
| 146 | 148 | */ |
@@ -24,12 +24,12 @@ discard block |
||
| 24 | 24 | { |
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | - * Get the field list into a database table |
|
| 28 | - * |
|
| 29 | - * @param string $table_name The name of the table we want to retrieve field list for |
|
| 30 | - * |
|
| 31 | - * @return object $field_list A wordpress database object containing the different field of the table |
|
| 32 | - */ |
|
| 27 | + * Get the field list into a database table |
|
| 28 | + * |
|
| 29 | + * @param string $table_name The name of the table we want to retrieve field list for |
|
| 30 | + * |
|
| 31 | + * @return object $field_list A wordpress database object containing the different field of the table |
|
| 32 | + */ |
|
| 33 | 33 | public static function get_field_list($table_name){ |
| 34 | 34 | global $wpdb; |
| 35 | 35 | |
@@ -39,12 +39,12 @@ discard block |
||
| 39 | 39 | return $field_list; |
| 40 | 40 | } |
| 41 | 41 | /** |
| 42 | - * Get a field defintion into a database table |
|
| 43 | - * |
|
| 44 | - * @param string $table_name The name of the table we want to retrieve field list for |
|
| 45 | - * |
|
| 46 | - * @return object $field A wordpress database object containing the field definition into the database table |
|
| 47 | - */ |
|
| 42 | + * Get a field defintion into a database table |
|
| 43 | + * |
|
| 44 | + * @param string $table_name The name of the table we want to retrieve field list for |
|
| 45 | + * |
|
| 46 | + * @return object $field A wordpress database object containing the field definition into the database table |
|
| 47 | + */ |
|
| 48 | 48 | function get_field_definition($table_name, $field){ |
| 49 | 49 | global $wpdb; |
| 50 | 50 | |
@@ -55,12 +55,12 @@ discard block |
||
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | - * Make a translation of the different database field type into a form input type |
|
| 59 | - * |
|
| 60 | - * @param string $table_name The name of the table we want to retrieve field input type for |
|
| 61 | - * |
|
| 62 | - * @return array $field_to_form An array with the list of field with its type, name and value |
|
| 63 | - */ |
|
| 58 | + * Make a translation of the different database field type into a form input type |
|
| 59 | + * |
|
| 60 | + * @param string $table_name The name of the table we want to retrieve field input type for |
|
| 61 | + * |
|
| 62 | + * @return array $field_to_form An array with the list of field with its type, name and value |
|
| 63 | + */ |
|
| 64 | 64 | public static function fields_to_input($table_name){ |
| 65 | 65 | $list_of_field_to_convert = wpshop_database::get_field_list($table_name); |
| 66 | 66 | |
@@ -70,12 +70,12 @@ discard block |
||
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |
| 73 | - * Transform the database table definition into an array for building a input for users |
|
| 74 | - * |
|
| 75 | - * @param array $list_of_field_to_convert The list of field we want to have the types for |
|
| 76 | - * |
|
| 77 | - * @return array $field_to_form The field stored into an array |
|
| 78 | - */ |
|
| 73 | + * Transform the database table definition into an array for building a input for users |
|
| 74 | + * |
|
| 75 | + * @param array $list_of_field_to_convert The list of field we want to have the types for |
|
| 76 | + * |
|
| 77 | + * @return array $field_to_form The field stored into an array |
|
| 78 | + */ |
|
| 79 | 79 | public static function fields_type($list_of_field_to_convert){ |
| 80 | 80 | $field_to_form = array(); |
| 81 | 81 | $i = 0; |
@@ -117,12 +117,12 @@ discard block |
||
| 117 | 117 | |
| 118 | 118 | |
| 119 | 119 | /** |
| 120 | - * Save a new attribute in database |
|
| 121 | - * |
|
| 122 | - * @param array $informationsToSet An array with the different information we want to set |
|
| 123 | - * |
|
| 124 | - * @return string $requestResponse A message that allows to know if the creation has been done correctly or not |
|
| 125 | - */ |
|
| 120 | + * Save a new attribute in database |
|
| 121 | + * |
|
| 122 | + * @param array $informationsToSet An array with the different information we want to set |
|
| 123 | + * |
|
| 124 | + * @return string $requestResponse A message that allows to know if the creation has been done correctly or not |
|
| 125 | + */ |
|
| 126 | 126 | public static function save($informationsToSet, $dataBaseTable){ |
| 127 | 127 | global $wpdb; |
| 128 | 128 | $requestResponse = ''; |
@@ -138,12 +138,12 @@ discard block |
||
| 138 | 138 | return $requestResponse; |
| 139 | 139 | } |
| 140 | 140 | /** |
| 141 | - * Update an existing attribute in database |
|
| 142 | - * |
|
| 143 | - * @param array $informationsToSet An array with the different information we want to set |
|
| 144 | - * |
|
| 145 | - * @return string $requestResponse A message that allows to know if the update has been done correctly or not |
|
| 146 | - */ |
|
| 141 | + * Update an existing attribute in database |
|
| 142 | + * |
|
| 143 | + * @param array $informationsToSet An array with the different information we want to set |
|
| 144 | + * |
|
| 145 | + * @return string $requestResponse A message that allows to know if the update has been done correctly or not |
|
| 146 | + */ |
|
| 147 | 147 | public static function update($informationsToSet, $id, $dataBaseTable){ |
| 148 | 148 | global $wpdb; |
| 149 | 149 | $requestResponse = ''; |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | |
| 3 | 3 | /* Check if file is include. No direct access possible with file url */ |
| 4 | -if ( !defined( 'WPSHOP_VERSION' ) ) { |
|
| 5 | - die( __('Access is not allowed by this way', 'wpshop') ); |
|
| 4 | +if (!defined('WPSHOP_VERSION')) { |
|
| 5 | + die(__('Access is not allowed by this way', 'wpshop')); |
|
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | /** |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @return object $field_list A wordpress database object containing the different field of the table |
| 32 | 32 | */ |
| 33 | - public static function get_field_list($table_name){ |
|
| 33 | + public static function get_field_list($table_name) { |
|
| 34 | 34 | global $wpdb; |
| 35 | 35 | |
| 36 | 36 | $query = "SHOW COLUMNS FROM " . $table_name; |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * |
| 46 | 46 | * @return object $field A wordpress database object containing the field definition into the database table |
| 47 | 47 | */ |
| 48 | - function get_field_definition($table_name, $field){ |
|
| 48 | + function get_field_definition($table_name, $field) { |
|
| 49 | 49 | global $wpdb; |
| 50 | 50 | |
| 51 | 51 | $query = $wpdb->prepare("SHOW COLUMNS FROM " . $table_name . " WHERE Field = %s", $field); |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | * |
| 62 | 62 | * @return array $field_to_form An array with the list of field with its type, name and value |
| 63 | 63 | */ |
| 64 | - public static function fields_to_input($table_name){ |
|
| 64 | + public static function fields_to_input($table_name) { |
|
| 65 | 65 | $list_of_field_to_convert = wpshop_database::get_field_list($table_name); |
| 66 | 66 | |
| 67 | 67 | $field_to_form = self::fields_type($list_of_field_to_convert); |
@@ -76,32 +76,32 @@ discard block |
||
| 76 | 76 | * |
| 77 | 77 | * @return array $field_to_form The field stored into an array |
| 78 | 78 | */ |
| 79 | - public static function fields_type($list_of_field_to_convert){ |
|
| 79 | + public static function fields_type($list_of_field_to_convert) { |
|
| 80 | 80 | $field_to_form = array(); |
| 81 | 81 | $i = 0; |
| 82 | - foreach ($list_of_field_to_convert as $Key => $field_definition){ |
|
| 82 | + foreach ($list_of_field_to_convert as $Key => $field_definition) { |
|
| 83 | 83 | $field_to_form[$i]['name'] = $field_definition->Field; |
| 84 | 84 | $field_to_form[$i]['value'] = $field_definition->Default; |
| 85 | 85 | |
| 86 | 86 | $type = 'text'; |
| 87 | - if(($field_definition->Key == 'PRI') || ($field_definition->Field == 'creation_date') || ($field_definition->Field == 'last_update_date')){ |
|
| 88 | - $type = 'hidden'; |
|
| 87 | + if (($field_definition->Key == 'PRI') || ($field_definition->Field == 'creation_date') || ($field_definition->Field == 'last_update_date')) { |
|
| 88 | + $type = 'hidden'; |
|
| 89 | 89 | } |
| 90 | - else{ |
|
| 91 | - $fieldtype = explode('(',$field_definition->Type); |
|
| 92 | - if(!empty($fieldtype[1]))$fieldtype[1] = str_replace(')','',$fieldtype[1]); |
|
| 90 | + else { |
|
| 91 | + $fieldtype = explode('(', $field_definition->Type); |
|
| 92 | + if (!empty($fieldtype[1]))$fieldtype[1] = str_replace(')', '', $fieldtype[1]); |
|
| 93 | 93 | |
| 94 | - if(($fieldtype[0] == 'char') || ($fieldtype[0] == 'varchar') || ($fieldtype[0] == 'int')) |
|
| 94 | + if (($fieldtype[0] == 'char') || ($fieldtype[0] == 'varchar') || ($fieldtype[0] == 'int')) |
|
| 95 | 95 | $type = 'text'; |
| 96 | - elseif($fieldtype[0] == 'text') |
|
| 96 | + elseif ($fieldtype[0] == 'text') |
|
| 97 | 97 | $type = 'textarea'; |
| 98 | - elseif($fieldtype[0] == 'enum') |
|
| 98 | + elseif ($fieldtype[0] == 'enum') |
|
| 99 | 99 | { |
| 100 | - $fieldtype[1] = str_replace("'","",$fieldtype[1]); |
|
| 101 | - $possible_value = explode(",",$fieldtype[1]); |
|
| 100 | + $fieldtype[1] = str_replace("'", "", $fieldtype[1]); |
|
| 101 | + $possible_value = explode(",", $fieldtype[1]); |
|
| 102 | 102 | |
| 103 | 103 | $type = 'radio'; |
| 104 | - if(count($possible_value) > 1) |
|
| 104 | + if (count($possible_value) > 1) |
|
| 105 | 105 | $type = 'select'; |
| 106 | 106 | |
| 107 | 107 | $field_to_form[$i]['possible_value'] = $possible_value; |
@@ -123,15 +123,15 @@ discard block |
||
| 123 | 123 | * |
| 124 | 124 | * @return string $requestResponse A message that allows to know if the creation has been done correctly or not |
| 125 | 125 | */ |
| 126 | - public static function save($informationsToSet, $dataBaseTable){ |
|
| 126 | + public static function save($informationsToSet, $dataBaseTable) { |
|
| 127 | 127 | global $wpdb; |
| 128 | 128 | $requestResponse = ''; |
| 129 | 129 | |
| 130 | 130 | $updateResult = $wpdb->insert($dataBaseTable, $informationsToSet, '%s'); |
| 131 | - if( $updateResult != false ){ |
|
| 131 | + if ($updateResult != false) { |
|
| 132 | 132 | $requestResponse = 'done'; |
| 133 | 133 | } |
| 134 | - else{ |
|
| 134 | + else { |
|
| 135 | 135 | $requestResponse = 'error'; |
| 136 | 136 | } |
| 137 | 137 | |
@@ -144,19 +144,19 @@ discard block |
||
| 144 | 144 | * |
| 145 | 145 | * @return string $requestResponse A message that allows to know if the update has been done correctly or not |
| 146 | 146 | */ |
| 147 | - public static function update($informationsToSet, $id, $dataBaseTable){ |
|
| 147 | + public static function update($informationsToSet, $id, $dataBaseTable) { |
|
| 148 | 148 | global $wpdb; |
| 149 | 149 | $requestResponse = ''; |
| 150 | 150 | |
| 151 | - $updateResult = $wpdb->update($dataBaseTable, $informationsToSet , array( 'id' => $id ), '%s', array('%d') ); |
|
| 151 | + $updateResult = $wpdb->update($dataBaseTable, $informationsToSet, array('id' => $id), '%s', array('%d')); |
|
| 152 | 152 | |
| 153 | - if( $updateResult == 1 ){ |
|
| 153 | + if ($updateResult == 1) { |
|
| 154 | 154 | $requestResponse = 'done'; |
| 155 | 155 | } |
| 156 | - elseif( $updateResult == 0 ){ |
|
| 156 | + elseif ($updateResult == 0) { |
|
| 157 | 157 | $requestResponse = 'nothingToUpdate'; |
| 158 | 158 | } |
| 159 | - elseif( $updateResult == false ){ |
|
| 159 | + elseif ($updateResult == false) { |
|
| 160 | 160 | $requestResponse = 'error'; |
| 161 | 161 | } |
| 162 | 162 | |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | |
| 3 | 5 | /* Check if file is include. No direct access possible with file url */ |
| 4 | 6 | if ( !defined( 'WPSHOP_VERSION' ) ) { |
@@ -86,23 +88,25 @@ discard block |
||
| 86 | 88 | $type = 'text'; |
| 87 | 89 | if(($field_definition->Key == 'PRI') || ($field_definition->Field == 'creation_date') || ($field_definition->Field == 'last_update_date')){ |
| 88 | 90 | $type = 'hidden'; |
| 89 | - } |
|
| 90 | - else{ |
|
| 91 | + } else{ |
|
| 91 | 92 | $fieldtype = explode('(',$field_definition->Type); |
| 92 | - if(!empty($fieldtype[1]))$fieldtype[1] = str_replace(')','',$fieldtype[1]); |
|
| 93 | + if(!empty($fieldtype[1])) { |
|
| 94 | + $fieldtype[1] = str_replace(')','',$fieldtype[1]); |
|
| 95 | + } |
|
| 93 | 96 | |
| 94 | - if(($fieldtype[0] == 'char') || ($fieldtype[0] == 'varchar') || ($fieldtype[0] == 'int')) |
|
| 95 | - $type = 'text'; |
|
| 96 | - elseif($fieldtype[0] == 'text') |
|
| 97 | - $type = 'textarea'; |
|
| 98 | - elseif($fieldtype[0] == 'enum') |
|
| 97 | + if(($fieldtype[0] == 'char') || ($fieldtype[0] == 'varchar') || ($fieldtype[0] == 'int')) { |
|
| 98 | + $type = 'text'; |
|
| 99 | + } elseif($fieldtype[0] == 'text') { |
|
| 100 | + $type = 'textarea'; |
|
| 101 | + } elseif($fieldtype[0] == 'enum') |
|
| 99 | 102 | { |
| 100 | 103 | $fieldtype[1] = str_replace("'","",$fieldtype[1]); |
| 101 | 104 | $possible_value = explode(",",$fieldtype[1]); |
| 102 | 105 | |
| 103 | 106 | $type = 'radio'; |
| 104 | - if(count($possible_value) > 1) |
|
| 105 | - $type = 'select'; |
|
| 107 | + if(count($possible_value) > 1) { |
|
| 108 | + $type = 'select'; |
|
| 109 | + } |
|
| 106 | 110 | |
| 107 | 111 | $field_to_form[$i]['possible_value'] = $possible_value; |
| 108 | 112 | } |
@@ -130,8 +134,7 @@ discard block |
||
| 130 | 134 | $updateResult = $wpdb->insert($dataBaseTable, $informationsToSet, '%s'); |
| 131 | 135 | if( $updateResult != false ){ |
| 132 | 136 | $requestResponse = 'done'; |
| 133 | - } |
|
| 134 | - else{ |
|
| 137 | + } else{ |
|
| 135 | 138 | $requestResponse = 'error'; |
| 136 | 139 | } |
| 137 | 140 | |
@@ -152,11 +155,9 @@ discard block |
||
| 152 | 155 | |
| 153 | 156 | if( $updateResult == 1 ){ |
| 154 | 157 | $requestResponse = 'done'; |
| 155 | - } |
|
| 156 | - elseif( $updateResult == 0 ){ |
|
| 158 | + } elseif( $updateResult == 0 ){ |
|
| 157 | 159 | $requestResponse = 'nothingToUpdate'; |
| 158 | - } |
|
| 159 | - elseif( $updateResult == false ){ |
|
| 160 | + } elseif( $updateResult == false ){ |
|
| 160 | 161 | $requestResponse = 'error'; |
| 161 | 162 | } |
| 162 | 163 | |
@@ -191,10 +191,10 @@ discard block |
||
| 191 | 191 | * Return a complete html table with header, body and content |
| 192 | 192 | * |
| 193 | 193 | * @param string $tableId The unique identifier of the table in the document |
| 194 | - * @param array $tableTitles An array with the different element to put into the table's header and footer |
|
| 194 | + * @param string[] $tableTitles An array with the different element to put into the table's header and footer |
|
| 195 | 195 | * @param array $tableRows An array with the different value to put into the table's body |
| 196 | - * @param array $tableClasses An array with the different class to affect to table rows and cols |
|
| 197 | - * @param array $tableRowsId An array with the different identifier for table lines |
|
| 196 | + * @param string[] $tableClasses An array with the different class to affect to table rows and cols |
|
| 197 | + * @param string[] $tableRowsId An array with the different identifier for table lines |
|
| 198 | 198 | * @param string $tableSummary A summary for the table |
| 199 | 199 | * @param boolean $withFooter Allow to define if the table must be create with a footer or not |
| 200 | 200 | * |
@@ -274,6 +274,7 @@ discard block |
||
| 274 | 274 | * |
| 275 | 275 | * @param string $file_name The file name to check if exists in current theme |
| 276 | 276 | * @param string $dir_name Optionnal The directory name of the file to check Default : wpshop |
| 277 | + * @param string $default_dir |
|
| 277 | 278 | * |
| 278 | 279 | * @return string $file_path The good filepath to include |
| 279 | 280 | */ |
@@ -299,7 +300,7 @@ discard block |
||
| 299 | 300 | * Check if the current shop use the first method for templates. One file per element to display |
| 300 | 301 | * |
| 301 | 302 | * @param string $template_part The part to take display for, will be usefull to check what file take in care if there were a file in old method |
| 302 | - * @param string $default_template_dirThe part of website to check template for. Possible values : wpshop / admin |
|
| 303 | + * @param string $default_template_dir part of website to check template for. Possible values : wpshop / admin |
|
| 303 | 304 | * |
| 304 | 305 | * @return array First index represent if there is a file for old version support, Second index represent the file to get for support old version |
| 305 | 306 | */ |
@@ -546,6 +547,7 @@ discard block |
||
| 546 | 547 | * @param string $part The part of shop where to display the given template element |
| 547 | 548 | * @param string $template_part The template element we want to display |
| 548 | 549 | * @param array $extras_args Allows to define some parameters to spot a specific template for example |
| 550 | + * @param string $default_template_dir |
|
| 549 | 551 | * |
| 550 | 552 | * @return string The good template to take in care, regarding on the given parameters |
| 551 | 553 | */ |
@@ -742,7 +744,7 @@ discard block |
||
| 742 | 744 | * Change output for product page |
| 743 | 745 | * |
| 744 | 746 | * @param string $content The content of a post |
| 745 | - * @return Ambigous <mixed, string>|unknown |
|
| 747 | + * @return string <mixed, string>|unknown |
|
| 746 | 748 | */ |
| 747 | 749 | public static function products_page( $content = '' ) { |
| 748 | 750 | global $wp_query; |
@@ -17,39 +17,39 @@ |
||
| 17 | 17 | class wpshop_display { |
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | - * Returns the header display of a classical HTML page. |
|
| 21 | - * |
|
| 22 | - * @see afficherFinPage |
|
| 23 | - * |
|
| 24 | - * @param string $pageTitle Title of the page. |
|
| 25 | - * @param string $pageIcon Path of the icon. |
|
| 26 | - * @param string $iconTitle Title attribute of the icon. |
|
| 27 | - * @param string $iconAlt Alt attribute of the icon. |
|
| 28 | - * @param boolean $hasAddButton Define if there must be a "add" button for this page |
|
| 29 | - * @param string $actionInformationMessage A message to display in case of action is send |
|
| 30 | - * |
|
| 31 | - * @return string Html code composing the page header |
|
| 32 | - */ |
|
| 20 | + * Returns the header display of a classical HTML page. |
|
| 21 | + * |
|
| 22 | + * @see afficherFinPage |
|
| 23 | + * |
|
| 24 | + * @param string $pageTitle Title of the page. |
|
| 25 | + * @param string $pageIcon Path of the icon. |
|
| 26 | + * @param string $iconTitle Title attribute of the icon. |
|
| 27 | + * @param string $iconAlt Alt attribute of the icon. |
|
| 28 | + * @param boolean $hasAddButton Define if there must be a "add" button for this page |
|
| 29 | + * @param string $actionInformationMessage A message to display in case of action is send |
|
| 30 | + * |
|
| 31 | + * @return string Html code composing the page header |
|
| 32 | + */ |
|
| 33 | 33 | public static function displayPageHeader($pageTitle, $pageIcon, $iconTitle, $iconAlt, $hasAddButton = true, $addButtonLink = '', $actionInformationMessage = '', $current_page_slug = ''){ |
| 34 | 34 | include(WPSHOP_TEMPLATES_DIR.'admin/admin_page_header.tpl.php'); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | - * Returns the end of a classical page |
|
| 39 | - * |
|
| 40 | - * @see displayPageHeader |
|
| 41 | - * |
|
| 42 | - * @return string Html code composing the page footer |
|
| 43 | - */ |
|
| 38 | + * Returns the end of a classical page |
|
| 39 | + * |
|
| 40 | + * @see displayPageHeader |
|
| 41 | + * |
|
| 42 | + * @return string Html code composing the page footer |
|
| 43 | + */ |
|
| 44 | 44 | public static function displayPageFooter($formActionButton){ |
| 45 | 45 | include(WPSHOP_TEMPLATES_DIR.'admin/admin_page_footer.tpl.php'); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | - * Return The complete output page code |
|
| 50 | - * |
|
| 51 | - * @return string The complete html page output |
|
| 52 | - */ |
|
| 49 | + * Return The complete output page code |
|
| 50 | + * |
|
| 51 | + * @return string The complete html page output |
|
| 52 | + */ |
|
| 53 | 53 | public static function display_page(){ |
| 54 | 54 | |
| 55 | 55 | $pageAddButton = false; |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | |
| 3 | 5 | /* Check if file is include. No direct access possible with file url */ |
| 4 | 6 | if ( !defined( 'WPSHOP_VERSION' ) ) { |
@@ -111,8 +113,7 @@ discard block |
||
| 111 | 113 | |
| 112 | 114 | if($outputType == 'listing'){ |
| 113 | 115 | $pageContent = $objectType->elementList(); |
| 114 | - } |
|
| 115 | - elseif($outputType == 'adding'){ |
|
| 116 | + } elseif($outputType == 'adding'){ |
|
| 116 | 117 | $pageAddButton = false; |
| 117 | 118 | |
| 118 | 119 | $pageFormButton = $objectType->getPageFormButton($objectToEdit); |
@@ -124,8 +125,7 @@ discard block |
||
| 124 | 125 | $pageMessage = $objectType->pageMessage; |
| 125 | 126 | if ( in_array( $objectType->getEditionSlug(), array(WPSHOP_URL_SLUG_ATTRIBUTE_LISTING, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING) ) ) { |
| 126 | 127 | $addButtonLink = admin_url('admin.php?page=' . $objectType->getEditionSlug() . '&action=add'); |
| 127 | - } |
|
| 128 | - else { |
|
| 128 | + } else { |
|
| 129 | 129 | $addButtonLink = admin_url('edit.php?post_type='.WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES.'&page=' . $objectType->getEditionSlug() . '&action=add'); |
| 130 | 130 | } |
| 131 | 131 | } |
@@ -287,8 +287,7 @@ discard block |
||
| 287 | 287 | $default_dir = get_stylesheet_directory(); |
| 288 | 288 | } |
| 289 | 289 | $file_path = $default_dir . '/' . $the_file; |
| 290 | - } |
|
| 291 | - else if ( !$check_only_custom ) { |
|
| 290 | + } else if ( !$check_only_custom ) { |
|
| 292 | 291 | $file_path = $default_dir . $the_file; |
| 293 | 292 | } |
| 294 | 293 | |
@@ -480,13 +479,17 @@ discard block |
||
| 480 | 479 | /* Get custom admin template */ |
| 481 | 480 | if ( is_file(get_stylesheet_directory() . '/admin/main_elements.tpl.php') ) { |
| 482 | 481 | require_once(get_stylesheet_directory() . '/admin/main_elements.tpl.php'); |
| 483 | - if (!empty($tpl_element)) |
|
| 484 | - $wpshop_template['admin']['custom'] = ($tpl_element);unset($tpl_element); |
|
| 482 | + if (!empty($tpl_element)) { |
|
| 483 | + $wpshop_template['admin']['custom'] = ($tpl_element); |
|
| 484 | + } |
|
| 485 | + unset($tpl_element); |
|
| 485 | 486 | } |
| 486 | 487 | if ( is_file(get_stylesheet_directory() . '/admin/wpshop_elements_template.tpl.php') ) { |
| 487 | 488 | require_once(get_stylesheet_directory() . '/admin/wpshop_elements_template.tpl.php'); |
| 488 | - if (!empty($tpl_element)) |
|
| 489 | - $wpshop_template['admin']['custom'] = ($tpl_element);unset($tpl_element); |
|
| 489 | + if (!empty($tpl_element)) { |
|
| 490 | + $wpshop_template['admin']['custom'] = ($tpl_element); |
|
| 491 | + } |
|
| 492 | + unset($tpl_element); |
|
| 490 | 493 | } |
| 491 | 494 | /* Get default frontend template */ |
| 492 | 495 | require_once(WPSHOP_TEMPLATES_DIR . 'wpshop/main_elements.tpl.php'); |
@@ -494,13 +497,17 @@ discard block |
||
| 494 | 497 | /* Get custom frontend template */ |
| 495 | 498 | if ( is_file(get_stylesheet_directory() . '/wpshop/main_elements.tpl.php') ) { |
| 496 | 499 | require_once(get_stylesheet_directory() . '/wpshop/main_elements.tpl.php'); |
| 497 | - if (!empty($tpl_element)) |
|
| 498 | - $wpshop_template['wpshop']['custom'] = ($tpl_element);unset($tpl_element); |
|
| 500 | + if (!empty($tpl_element)) { |
|
| 501 | + $wpshop_template['wpshop']['custom'] = ($tpl_element); |
|
| 502 | + } |
|
| 503 | + unset($tpl_element); |
|
| 499 | 504 | } |
| 500 | 505 | if ( is_file(get_stylesheet_directory() . '/wpshop/wpshop_elements_template.tpl.php') ) { |
| 501 | 506 | require_once(get_stylesheet_directory() . '/wpshop/wpshop_elements_template.tpl.php'); |
| 502 | - if (!empty($tpl_element)) |
|
| 503 | - $wpshop_template['wpshop']['custom'] = ($tpl_element);unset($tpl_element); |
|
| 507 | + if (!empty($tpl_element)) { |
|
| 508 | + $wpshop_template['wpshop']['custom'] = ($tpl_element); |
|
| 509 | + } |
|
| 510 | + unset($tpl_element); |
|
| 504 | 511 | } |
| 505 | 512 | foreach ( $wpshop_template as $site_side => $types ) { |
| 506 | 513 | foreach ( $types as $type => $tpl_component ) { |
@@ -557,8 +564,7 @@ discard block |
||
| 557 | 564 | |
| 558 | 565 | if ( !empty($extras_args['type']) && !empty($extras_args['id']) && !empty( $template[$default_template_dir][$part]) && !empty($extras_args['page']) && !empty( $template[$default_template_dir][$part][$extras_args['page']] ) && !empty( $template[$default_template_dir][$part][$extras_args['page']][$extras_args['type']]) && !empty( $template[$default_template_dir][$part][$extras_args['page']][$extras_args['type']][$extras_args['id']] ) && !empty( $template[$default_template_dir][$part][$extras_args['page']][$extras_args['type']][$extras_args['id']][$template_part] ) ) { |
| 559 | 566 | $tpl_element_to_return = $template[$default_template_dir][$part][$extras_args['page']][$extras_args['type']][$extras_args['id']][$template_part]; |
| 560 | - } |
|
| 561 | - elseif ( !empty($extras_args['type']) && !empty($extras_args['id']) && !empty( $template[$default_template_dir][$part][$extras_args['type']]) && !empty( $template[$default_template_dir][$part][$extras_args['type']][$extras_args['id']] ) && !empty( $template[$default_template_dir][$part][$extras_args['type']][$extras_args['id']][$template_part] ) ) { |
|
| 567 | + } elseif ( !empty($extras_args['type']) && !empty($extras_args['id']) && !empty( $template[$default_template_dir][$part][$extras_args['type']]) && !empty( $template[$default_template_dir][$part][$extras_args['type']][$extras_args['id']] ) && !empty( $template[$default_template_dir][$part][$extras_args['type']][$extras_args['id']][$template_part] ) ) { |
|
| 562 | 568 | $tpl_element_to_return = $template[$default_template_dir][$part][$extras_args['type']][$extras_args['id']][$template_part]; |
| 563 | 569 | } |
| 564 | 570 | /** Check if the file have been duplicated into theme directory for customization */ |
@@ -591,7 +597,9 @@ discard block |
||
| 591 | 597 | $template_to_fill = str_replace('{WPSHOP_'.$element.'}', $value, $template_to_fill); |
| 592 | 598 | } |
| 593 | 599 | } |
| 594 | - if (WPSHOP_DISPLAY_AVAILABLE_KEYS_FOR_TEMPLATE) $template_to_fill = '<!-- Available keys : ' . implode(' / ', $available_key) . ' -->' . $template_to_fill; |
|
| 600 | + if (WPSHOP_DISPLAY_AVAILABLE_KEYS_FOR_TEMPLATE) { |
|
| 601 | + $template_to_fill = '<!-- Available keys : ' . implode(' / ', $available_key) . ' -->' . $template_to_fill; |
|
| 602 | + } |
|
| 595 | 603 | |
| 596 | 604 | return $template_to_fill; |
| 597 | 605 | } |
@@ -655,8 +663,7 @@ discard block |
||
| 655 | 663 | /* Enable shortcodes in category, taxonomy, tag descriptions */ |
| 656 | 664 | if(function_exists('term_description')) { |
| 657 | 665 | add_filter('term_description', 'do_shortcode'); |
| 658 | - } |
|
| 659 | - else { |
|
| 666 | + } else { |
|
| 660 | 667 | add_filter('category_description', 'do_shortcode'); |
| 661 | 668 | } |
| 662 | 669 | } |
@@ -686,8 +693,7 @@ discard block |
||
| 686 | 693 | if( in_array($pagenow, array('edit-tags.php')) ) { |
| 687 | 694 | $editor_id = 'tag_description'; |
| 688 | 695 | $editor_selector = 'description'; |
| 689 | - } |
|
| 690 | - else { |
|
| 696 | + } else { |
|
| 691 | 697 | $editor_id = $editor_selector = 'category_description'; |
| 692 | 698 | } |
| 693 | 699 | |
@@ -749,8 +755,7 @@ discard block |
||
| 749 | 755 | |
| 750 | 756 | if (!empty($wp_query->queried_object) && !empty($wp_query->queried_object->post_type) && ($wp_query->queried_object->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT)) { |
| 751 | 757 | return wpshop_products::product_complete_sheet_output($content, $wp_query->post->ID); |
| 752 | - } |
|
| 753 | - else { |
|
| 758 | + } else { |
|
| 754 | 759 | return $content; |
| 755 | 760 | } |
| 756 | 761 | } |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | |
| 3 | 3 | /* Check if file is include. No direct access possible with file url */ |
| 4 | -if ( !defined( 'WPSHOP_VERSION' ) ) { |
|
| 5 | - die( __('Access is not allowed by this way', 'wpshop') ); |
|
| 4 | +if (!defined('WPSHOP_VERSION')) { |
|
| 5 | + die(__('Access is not allowed by this way', 'wpshop')); |
|
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | /** |
@@ -30,8 +30,8 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @return string Html code composing the page header |
| 32 | 32 | */ |
| 33 | - public static function displayPageHeader($pageTitle, $pageIcon, $iconTitle, $iconAlt, $hasAddButton = true, $addButtonLink = '', $actionInformationMessage = '', $current_page_slug = ''){ |
|
| 34 | - include(WPSHOP_TEMPLATES_DIR.'admin/admin_page_header.tpl.php'); |
|
| 33 | + public static function displayPageHeader($pageTitle, $pageIcon, $iconTitle, $iconAlt, $hasAddButton = true, $addButtonLink = '', $actionInformationMessage = '', $current_page_slug = '') { |
|
| 34 | + include(WPSHOP_TEMPLATES_DIR . 'admin/admin_page_header.tpl.php'); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -41,8 +41,8 @@ discard block |
||
| 41 | 41 | * |
| 42 | 42 | * @return string Html code composing the page footer |
| 43 | 43 | */ |
| 44 | - public static function displayPageFooter($formActionButton){ |
|
| 45 | - include(WPSHOP_TEMPLATES_DIR.'admin/admin_page_footer.tpl.php'); |
|
| 44 | + public static function displayPageFooter($formActionButton) { |
|
| 45 | + include(WPSHOP_TEMPLATES_DIR . 'admin/admin_page_footer.tpl.php'); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * |
| 51 | 51 | * @return string The complete html page output |
| 52 | 52 | */ |
| 53 | - public static function display_page(){ |
|
| 53 | + public static function display_page() { |
|
| 54 | 54 | |
| 55 | 55 | $pageAddButton = false; |
| 56 | 56 | $pageMessage = $addButtonLink = $pageFormButton = $pageIcon = $pageIconTitle = $pageIconAlt = $objectType = ''; |
@@ -60,13 +60,13 @@ discard block |
||
| 60 | 60 | $action = isset($_REQUEST['action']) ? wpshop_tools::varSanitizer($_REQUEST['action']) : ''; |
| 61 | 61 | |
| 62 | 62 | /* Select the content to add to the page looking for the parameter */ |
| 63 | - switch($pageSlug){ |
|
| 63 | + switch ($pageSlug) { |
|
| 64 | 64 | case WPSHOP_URL_SLUG_ATTRIBUTE_LISTING: |
| 65 | 65 | $objectType = new wpshop_attributes(); |
| 66 | 66 | $current_user_can_edit = current_user_can('wpshop_edit_attributes'); |
| 67 | 67 | $current_user_can_add = current_user_can('wpshop_add_attributes'); |
| 68 | 68 | $current_user_can_delete = current_user_can('wpshop_delete_attributes'); |
| 69 | - if(current_user_can('wpshop_add_attributes')){ |
|
| 69 | + if (current_user_can('wpshop_add_attributes')) { |
|
| 70 | 70 | $pageAddButton = true; |
| 71 | 71 | } |
| 72 | 72 | break; |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | $current_user_can_edit = current_user_can('wpshop_edit_attribute_set'); |
| 76 | 76 | $current_user_can_add = current_user_can('wpshop_add_attribute_set'); |
| 77 | 77 | $current_user_can_delete = current_user_can('wpshop_delete_attribute_set'); |
| 78 | - if(current_user_can('wpshop_add_attribute_set')){ |
|
| 78 | + if (current_user_can('wpshop_add_attribute_set')) { |
|
| 79 | 79 | $pageAddButton = true; |
| 80 | 80 | } |
| 81 | 81 | break; |
@@ -88,20 +88,20 @@ discard block |
||
| 88 | 88 | $pageAddButton = false; |
| 89 | 89 | $objectType = new wpshop_messages(); |
| 90 | 90 | $current_user_can_edit = true; |
| 91 | - $mid = !empty( $_GET['mid'] ) ? sanitize_text_field( $_GET['mid'] ) : ''; |
|
| 92 | - if(!empty($mid)){ |
|
| 91 | + $mid = !empty($_GET['mid']) ? sanitize_text_field($_GET['mid']) : ''; |
|
| 92 | + if (!empty($mid)) { |
|
| 93 | 93 | $action = 'edit'; |
| 94 | 94 | } |
| 95 | 95 | break; |
| 96 | 96 | default:{ |
| 97 | - $pageTitle = sprintf(__('You have to add this page into %s at line %s', 'wpshop'), __FILE__, (__LINE__ - 4)); |
|
| 97 | + $pageTitle = sprintf(__('You have to add this page into %s at line %s', 'wpshop'), __FILE__, (__LINE__ -4)); |
|
| 98 | 98 | $pageAddButton = false; |
| 99 | 99 | } |
| 100 | 100 | break; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - if($objectType != ''){ |
|
| 104 | - if(($action != '') && ((($action == 'edit') && $current_user_can_edit) || (($action == 'add') && $current_user_can_add) || (($action == 'delete') && $current_user_can_delete))){ |
|
| 103 | + if ($objectType != '') { |
|
| 104 | + if (($action != '') && ((($action == 'edit') && $current_user_can_edit) || (($action == 'add') && $current_user_can_add) || (($action == 'delete') && $current_user_can_delete))) { |
|
| 105 | 105 | $outputType = 'adding'; |
| 106 | 106 | } |
| 107 | 107 | $objectType->elementAction(); |
@@ -110,10 +110,10 @@ discard block |
||
| 110 | 110 | $pageIconTitle = self::getPageIconInformation('title', $objectType); |
| 111 | 111 | $pageIconAlt = self::getPageIconInformation('alt', $objectType); |
| 112 | 112 | |
| 113 | - if($outputType == 'listing'){ |
|
| 113 | + if ($outputType == 'listing') { |
|
| 114 | 114 | $pageContent = $objectType->elementList(); |
| 115 | 115 | } |
| 116 | - elseif($outputType == 'adding'){ |
|
| 116 | + elseif ($outputType == 'adding') { |
|
| 117 | 117 | $pageAddButton = false; |
| 118 | 118 | |
| 119 | 119 | $pageFormButton = $objectType->getPageFormButton($objectToEdit); |
@@ -123,11 +123,11 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | $pageTitle = $objectType->pageTitle(); |
| 125 | 125 | $pageMessage = $objectType->pageMessage; |
| 126 | - if ( in_array( $objectType->getEditionSlug(), array(WPSHOP_URL_SLUG_ATTRIBUTE_LISTING, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING) ) ) { |
|
| 126 | + if (in_array($objectType->getEditionSlug(), array(WPSHOP_URL_SLUG_ATTRIBUTE_LISTING, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING))) { |
|
| 127 | 127 | $addButtonLink = admin_url('admin.php?page=' . $objectType->getEditionSlug() . '&action=add'); |
| 128 | 128 | } |
| 129 | 129 | else { |
| 130 | - $addButtonLink = admin_url('edit.php?post_type='.WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES.'&page=' . $objectType->getEditionSlug() . '&action=add'); |
|
| 130 | + $addButtonLink = admin_url('edit.php?post_type=' . WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES . '&page=' . $objectType->getEditionSlug() . '&action=add'); |
|
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | |
@@ -149,37 +149,37 @@ discard block |
||
| 149 | 149 | * |
| 150 | 150 | * @return string The output builded from selected type |
| 151 | 151 | */ |
| 152 | - public static function custom_page_output_builder($content, $output_type='tab') { |
|
| 152 | + public static function custom_page_output_builder($content, $output_type = 'tab') { |
|
| 153 | 153 | $output_custom_layout = ''; |
| 154 | 154 | |
| 155 | - switch ( $output_type ) { |
|
| 155 | + switch ($output_type) { |
|
| 156 | 156 | case 'separated_bloc': |
| 157 | - foreach ( $content as $element_type => $element_type_details ) { |
|
| 158 | - $output_custom_layout.=' |
|
| 159 | - <div class="wpshop_separated_bloc wpshop_separated_bloc_'.$element_type.'" >'; |
|
| 160 | - foreach ( $element_type_details as $element_type_key => $element_type_content ) { |
|
| 161 | - $output_custom_layout.=' |
|
| 162 | - <div class="wpshop_admin_box wpshop_admin_box_'.$element_type.' wpshop_admin_box_'.$element_type.'_'.$element_type_key.'" > |
|
| 157 | + foreach ($content as $element_type => $element_type_details) { |
|
| 158 | + $output_custom_layout .= ' |
|
| 159 | + <div class="wpshop_separated_bloc wpshop_separated_bloc_'.$element_type . '" >'; |
|
| 160 | + foreach ($element_type_details as $element_type_key => $element_type_content) { |
|
| 161 | + $output_custom_layout .= ' |
|
| 162 | + <div class="wpshop_admin_box wpshop_admin_box_'.$element_type . ' wpshop_admin_box_' . $element_type . '_' . $element_type_key . '" > |
|
| 163 | 163 | <h3>' . $element_type_content['title'] . '</h3>' . $element_type_content['content'] . ' |
| 164 | 164 | </div>'; |
| 165 | 165 | } |
| 166 | - $output_custom_layout.=' |
|
| 166 | + $output_custom_layout .= ' |
|
| 167 | 167 | </div>'; |
| 168 | 168 | } |
| 169 | 169 | break; |
| 170 | 170 | case 'tab': |
| 171 | - $tab_list=$tab_content_list=''; |
|
| 172 | - foreach ( $content as $element_type => $element_type_details ) { |
|
| 173 | - foreach ( $element_type_details as $element_type_key => $element_type_content ) { |
|
| 174 | - $tab_list.=' |
|
| 175 | - <li><a href="#wpshop_'.$element_type.'_'.$element_type_key.'" >'.$element_type_content['title'].'</a></li>'; |
|
| 176 | - $tab_content_list.=' |
|
| 177 | - <div id="wpshop_'.$element_type.'_'.$element_type_key.'" class="wpshop_admin_box wpshop_admin_box_'.$element_type.' wpshop_admin_box_'.$element_type.'_'.$element_type_key.'" >'.$element_type_content['content'].' |
|
| 171 | + $tab_list = $tab_content_list = ''; |
|
| 172 | + foreach ($content as $element_type => $element_type_details) { |
|
| 173 | + foreach ($element_type_details as $element_type_key => $element_type_content) { |
|
| 174 | + $tab_list .= ' |
|
| 175 | + <li><a href="#wpshop_'.$element_type . '_' . $element_type_key . '" >' . $element_type_content['title'] . '</a></li>'; |
|
| 176 | + $tab_content_list .= ' |
|
| 177 | + <div id="wpshop_'.$element_type . '_' . $element_type_key . '" class="wpshop_admin_box wpshop_admin_box_' . $element_type . ' wpshop_admin_box_' . $element_type . '_' . $element_type_key . '" >' . $element_type_content['content'] . ' |
|
| 178 | 178 | </div>'; |
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | - $output_custom_layout.=' |
|
| 182 | - <div id="wpshopFormManagementContainer" class="wpshop_tabs wpshop_full_page_tabs wpshop_'.$element_type.'_tabs" > |
|
| 181 | + $output_custom_layout .= ' |
|
| 182 | + <div id="wpshopFormManagementContainer" class="wpshop_tabs wpshop_full_page_tabs wpshop_'.$element_type . '_tabs" > |
|
| 183 | 183 | <ul>' . $tab_list . '</ul>' . $tab_content_list . ' |
| 184 | 184 | </div>'; |
| 185 | 185 | break; |
@@ -201,21 +201,21 @@ discard block |
||
| 201 | 201 | * |
| 202 | 202 | * @return string $table The html code of the table to output |
| 203 | 203 | */ |
| 204 | - public static function getTable($tableId, $tableTitles, $tableRows, $tableClasses, $tableRowsId, $tableSummary = '', $withFooter = true){ |
|
| 204 | + public static function getTable($tableId, $tableTitles, $tableRows, $tableClasses, $tableRowsId, $tableSummary = '', $withFooter = true) { |
|
| 205 | 205 | $tableTitleBar = $tableBody = ''; |
| 206 | 206 | |
| 207 | 207 | /* Create the header and footer row */ |
| 208 | - for($i=0; $i<count($tableTitles); $i++){ |
|
| 208 | + for ($i = 0; $i < count($tableTitles); $i++) { |
|
| 209 | 209 | $tableTitleBar .= ' |
| 210 | 210 | <th class="' . $tableClasses[$i] . '" scope="col" >' . $tableTitles[$i] . '</th>'; |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | /* Create each table row */ |
| 214 | - for($lineNumber=0; $lineNumber<count($tableRows); $lineNumber++){ |
|
| 214 | + for ($lineNumber = 0; $lineNumber < count($tableRows); $lineNumber++) { |
|
| 215 | 215 | $tableRow = $tableRows[$lineNumber]; |
| 216 | 216 | $tableBody .= ' |
| 217 | 217 | <tr id="' . $tableRowsId[$lineNumber] . '" class="tableRow" >'; |
| 218 | - for($i=0; $i<count($tableRow); $i++){ |
|
| 218 | + for ($i = 0; $i < count($tableRow); $i++) { |
|
| 219 | 219 | $tableBody .= ' |
| 220 | 220 | <td class="' . $tableClasses[$i] . ' ' . $tableRow[$i]['class'] . '" >' . $tableRow[$i]['value'] . '</td>'; |
| 221 | 221 | } |
@@ -226,13 +226,13 @@ discard block |
||
| 226 | 226 | /* Create the table output */ |
| 227 | 227 | $table = ' |
| 228 | 228 | <table id="' . $tableId . '" cellspacing="0" cellpadding="0" class="widefat post fixed" >'; |
| 229 | - if($tableTitleBar != ''){ |
|
| 229 | + if ($tableTitleBar != '') { |
|
| 230 | 230 | $table .= ' |
| 231 | 231 | <thead> |
| 232 | 232 | <tr class="tableTitleHeader" >' . $tableTitleBar . ' |
| 233 | 233 | </tr> |
| 234 | 234 | </thead>'; |
| 235 | - if($withFooter){ |
|
| 235 | + if ($withFooter) { |
|
| 236 | 236 | $table .= ' |
| 237 | 237 | <tfoot> |
| 238 | 238 | <tr class="tableTitleFooter" >' . $tableTitleBar . ' |
@@ -255,8 +255,8 @@ discard block |
||
| 255 | 255 | * |
| 256 | 256 | * @return string $pageIconInformation The information to output in the page |
| 257 | 257 | */ |
| 258 | - public static function getPageIconInformation($infoType, $object){ |
|
| 259 | - switch($infoType){ |
|
| 258 | + public static function getPageIconInformation($infoType, $object) { |
|
| 259 | + switch ($infoType) { |
|
| 260 | 260 | case 'path': |
| 261 | 261 | $pageIconInformation = $object->pageIcon; |
| 262 | 262 | break; |
@@ -278,18 +278,18 @@ discard block |
||
| 278 | 278 | * |
| 279 | 279 | * @return string $file_path The good filepath to include |
| 280 | 280 | */ |
| 281 | - public static function get_template_file($file_name, $default_dir = WPSHOP_TEMPLATES_DIR, $dir_name = 'wpshop', $usage_type = 'include', $check_only_custom = false){ |
|
| 281 | + public static function get_template_file($file_name, $default_dir = WPSHOP_TEMPLATES_DIR, $dir_name = 'wpshop', $usage_type = 'include', $check_only_custom = false) { |
|
| 282 | 282 | $file_path = ''; |
| 283 | 283 | $the_file = $dir_name . '/' . $file_name; |
| 284 | 284 | |
| 285 | 285 | if (is_file(get_stylesheet_directory() . '/' . $the_file)) { |
| 286 | 286 | $default_dir = str_replace(WP_CONTENT_DIR, WP_CONTENT_URL, get_stylesheet_directory()); |
| 287 | - if($usage_type == 'include'){ |
|
| 287 | + if ($usage_type == 'include') { |
|
| 288 | 288 | $default_dir = get_stylesheet_directory(); |
| 289 | 289 | } |
| 290 | 290 | $file_path = $default_dir . '/' . $the_file; |
| 291 | 291 | } |
| 292 | - else if ( !$check_only_custom ) { |
|
| 292 | + else if (!$check_only_custom) { |
|
| 293 | 293 | $file_path = $default_dir . $the_file; |
| 294 | 294 | } |
| 295 | 295 | |
@@ -312,124 +312,124 @@ discard block |
||
| 312 | 312 | $custom_template_part = get_stylesheet_directory() . '/' . $default_template_dir . '/'; |
| 313 | 313 | |
| 314 | 314 | /** Let support the old way of template managing */ |
| 315 | - switch ( $template_part ) { |
|
| 315 | + switch ($template_part) { |
|
| 316 | 316 | case 'category_mini_list': |
| 317 | 317 | $old_file_to_take_care_url = 'category-mini-list.tpl.php'; |
| 318 | - if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) : |
|
| 318 | + if (is_file($custom_template_part . $old_file_to_take_care_url)) : |
|
| 319 | 319 | $old_file_to_take_care = true; |
| 320 | 320 | endif; |
| 321 | 321 | break; |
| 322 | 322 | case 'category_mini_grid': |
| 323 | 323 | $old_file_to_take_care_url = 'category-mini-grid.tpl.php'; |
| 324 | - if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) : |
|
| 324 | + if (is_file($custom_template_part . $old_file_to_take_care_url)) : |
|
| 325 | 325 | $old_file_to_take_care = true; |
| 326 | 326 | endif; |
| 327 | 327 | break; |
| 328 | 328 | case 'product_complete_tpl': |
| 329 | 329 | $old_file_to_take_care_url = 'product.tpl.php'; |
| 330 | - if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) : |
|
| 330 | + if (is_file($custom_template_part . $old_file_to_take_care_url)) : |
|
| 331 | 331 | $old_file_to_take_care = true; |
| 332 | 332 | endif; |
| 333 | 333 | break; |
| 334 | 334 | case 'product_mini_list': |
| 335 | 335 | $old_file_to_take_care_url = 'product-mini-list.tpl.php'; |
| 336 | - if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) : |
|
| 336 | + if (is_file($custom_template_part . $old_file_to_take_care_url)) : |
|
| 337 | 337 | $old_file_to_take_care = true; |
| 338 | 338 | endif; |
| 339 | 339 | break; |
| 340 | 340 | case 'product_mini_grid': |
| 341 | 341 | $old_file_to_take_care_url = 'product-mini-grid.tpl.php'; |
| 342 | - if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) : |
|
| 342 | + if (is_file($custom_template_part . $old_file_to_take_care_url)) : |
|
| 343 | 343 | $old_file_to_take_care = true; |
| 344 | 344 | endif; |
| 345 | 345 | break; |
| 346 | 346 | case 'product_listing_sorting': |
| 347 | 347 | $old_file_to_take_care_url = 'product_listing_sorting.tpl.php'; |
| 348 | - if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) : |
|
| 348 | + if (is_file($custom_template_part . $old_file_to_take_care_url)) : |
|
| 349 | 349 | $old_file_to_take_care = true; |
| 350 | 350 | endif; |
| 351 | 351 | break; |
| 352 | 352 | case 'unavailable_product_button': |
| 353 | 353 | $old_file_to_take_care_url = 'not_available_product_button.tpl.php'; |
| 354 | - if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) : |
|
| 354 | + if (is_file($custom_template_part . $old_file_to_take_care_url)) : |
|
| 355 | 355 | $old_file_to_take_care = true; |
| 356 | 356 | endif; |
| 357 | 357 | break; |
| 358 | 358 | case 'add_to_cart_button': |
| 359 | 359 | $old_file_to_take_care_url = 'available_product_button.tpl.php'; |
| 360 | - if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) : |
|
| 360 | + if (is_file($custom_template_part . $old_file_to_take_care_url)) : |
|
| 361 | 361 | $old_file_to_take_care = true; |
| 362 | 362 | endif; |
| 363 | 363 | break; |
| 364 | 364 | case 'ask_quotation_button': |
| 365 | 365 | $old_file_to_take_care_url = 'quotation_button.tpl.php'; |
| 366 | - if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) : |
|
| 366 | + if (is_file($custom_template_part . $old_file_to_take_care_url)) : |
|
| 367 | 367 | $old_file_to_take_care = true; |
| 368 | 368 | endif; |
| 369 | 369 | break; |
| 370 | 370 | case 'mini_cart_content': |
| 371 | 371 | $old_file_to_take_care_url = 'wpshop_mini_cart.tpl.php'; |
| 372 | - if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) : |
|
| 372 | + if (is_file($custom_template_part . $old_file_to_take_care_url)) : |
|
| 373 | 373 | $old_file_to_take_care = true; |
| 374 | 374 | endif; |
| 375 | 375 | break; |
| 376 | 376 | case 'product_is_new_sticker': |
| 377 | 377 | $old_file_to_take_care_url = 'product-is-new.tpl.php'; |
| 378 | - if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) : |
|
| 378 | + if (is_file($custom_template_part . $old_file_to_take_care_url)) : |
|
| 379 | 379 | $old_file_to_take_care = true; |
| 380 | 380 | endif; |
| 381 | 381 | break; |
| 382 | 382 | case 'product_is_featured_sticker': |
| 383 | 383 | $old_file_to_take_care_url = 'product-is-featured.tpl.php'; |
| 384 | - if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) : |
|
| 384 | + if (is_file($custom_template_part . $old_file_to_take_care_url)) : |
|
| 385 | 385 | $old_file_to_take_care = true; |
| 386 | 386 | endif; |
| 387 | 387 | break; |
| 388 | 388 | case 'product_attribute_container': |
| 389 | 389 | $old_file_to_take_care_url = 'product-attribute-front-display-main-container.tpl.php'; |
| 390 | - if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) : |
|
| 390 | + if (is_file($custom_template_part . $old_file_to_take_care_url)) : |
|
| 391 | 391 | $old_file_to_take_care = true; |
| 392 | 392 | endif; |
| 393 | 393 | break; |
| 394 | 394 | case 'product_attribute_tabs': |
| 395 | 395 | $old_file_to_take_care_url = 'product-attribute-front-display-tabs.tpl.php'; |
| 396 | - if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) : |
|
| 396 | + if (is_file($custom_template_part . $old_file_to_take_care_url)) : |
|
| 397 | 397 | $old_file_to_take_care = true; |
| 398 | 398 | endif; |
| 399 | 399 | break; |
| 400 | 400 | case 'product_attribute_tabs_detail': |
| 401 | 401 | $old_file_to_take_care_url = 'product-attribute-front-display-tabs-content.tpl.php'; |
| 402 | - if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) : |
|
| 402 | + if (is_file($custom_template_part . $old_file_to_take_care_url)) : |
|
| 403 | 403 | $old_file_to_take_care = true; |
| 404 | 404 | endif; |
| 405 | 405 | break; |
| 406 | 406 | case 'product_attachment_picture_galery': |
| 407 | 407 | $old_file_to_take_care_url = 'product_picture_galery.tpl.php'; |
| 408 | - if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) : |
|
| 408 | + if (is_file($custom_template_part . $old_file_to_take_care_url)) : |
|
| 409 | 409 | $old_file_to_take_care = true; |
| 410 | 410 | endif; |
| 411 | 411 | break; |
| 412 | 412 | case 'product_attachment_galery': |
| 413 | 413 | $old_file_to_take_care_url = 'product_document_library.tpl.php'; |
| 414 | - if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) : |
|
| 414 | + if (is_file($custom_template_part . $old_file_to_take_care_url)) : |
|
| 415 | 415 | $old_file_to_take_care = true; |
| 416 | 416 | endif; |
| 417 | 417 | break; |
| 418 | 418 | case 'product_attachment_item_picture': |
| 419 | 419 | $old_file_to_take_care_url = 'product_attachment_picture_line.tpl.php'; |
| 420 | - if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) : |
|
| 420 | + if (is_file($custom_template_part . $old_file_to_take_care_url)) : |
|
| 421 | 421 | $old_file_to_take_care = true; |
| 422 | 422 | endif; |
| 423 | 423 | break; |
| 424 | 424 | case 'product_attachment_item_document': |
| 425 | 425 | $old_file_to_take_care_url = 'product_attachment_document_line.tpl.php'; |
| 426 | - if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) : |
|
| 426 | + if (is_file($custom_template_part . $old_file_to_take_care_url)) : |
|
| 427 | 427 | $old_file_to_take_care = true; |
| 428 | 428 | endif; |
| 429 | 429 | break; |
| 430 | 430 | case 'product_added_to_cart_message': |
| 431 | 431 | $old_file_to_take_care_url = 'product_added_to_cart_message.tpl.php'; |
| 432 | - if ( is_file($custom_template_part . $old_file_to_take_care_url ) ) : |
|
| 432 | + if (is_file($custom_template_part . $old_file_to_take_care_url)) : |
|
| 433 | 433 | $old_file_to_take_care = true; |
| 434 | 434 | endif; |
| 435 | 435 | break; |
@@ -459,13 +459,13 @@ discard block |
||
| 459 | 459 | */ |
| 460 | 460 | public static function display_template_element($template_part, $template_part_component, $extras_args = array(), $default_template_dir = 'wpshop') { |
| 461 | 461 | /** Set the template element to return by default before checking if custom exists in order to be sure to return something */ |
| 462 | - $default_template_element = wpshop_display::check_template_to_display( 'default', $template_part, $extras_args, $default_template_dir ); |
|
| 462 | + $default_template_element = wpshop_display::check_template_to_display('default', $template_part, $extras_args, $default_template_dir); |
|
| 463 | 463 | |
| 464 | 464 | /** Check in custom template if there is not a custom element to display for current */ |
| 465 | - $custom_template_element = wpshop_display::check_template_to_display( 'custom', $template_part, $extras_args, $default_template_dir ); |
|
| 465 | + $custom_template_element = wpshop_display::check_template_to_display('custom', $template_part, $extras_args, $default_template_dir); |
|
| 466 | 466 | $tpl_element_to_return = !empty($custom_template_element) ? $custom_template_element : $default_template_element; |
| 467 | 467 | |
| 468 | - $template_part_component = apply_filters( 'wps_filter_display_' . $template_part, $template_part_component, $extras_args, $default_template_dir ); |
|
| 468 | + $template_part_component = apply_filters('wps_filter_display_' . $template_part, $template_part_component, $extras_args, $default_template_dir); |
|
| 469 | 469 | |
| 470 | 470 | return self::feed_template($tpl_element_to_return, $template_part_component); |
| 471 | 471 | } |
@@ -477,44 +477,44 @@ discard block |
||
| 477 | 477 | /* Load template component */ |
| 478 | 478 | /* Get default admin template */ |
| 479 | 479 | require_once(WPSHOP_TEMPLATES_DIR . 'admin/main_elements.tpl.php'); |
| 480 | - $wpshop_template['admin']['default'] = ($tpl_element);unset($tpl_element); |
|
| 480 | + $wpshop_template['admin']['default'] = ($tpl_element); unset($tpl_element); |
|
| 481 | 481 | /* Get custom admin template */ |
| 482 | - if ( is_file(get_stylesheet_directory() . '/admin/main_elements.tpl.php') ) { |
|
| 482 | + if (is_file(get_stylesheet_directory() . '/admin/main_elements.tpl.php')) { |
|
| 483 | 483 | require_once(get_stylesheet_directory() . '/admin/main_elements.tpl.php'); |
| 484 | 484 | if (!empty($tpl_element)) |
| 485 | - $wpshop_template['admin']['custom'] = ($tpl_element);unset($tpl_element); |
|
| 485 | + $wpshop_template['admin']['custom'] = ($tpl_element); unset($tpl_element); |
|
| 486 | 486 | } |
| 487 | - if ( is_file(get_stylesheet_directory() . '/admin/wpshop_elements_template.tpl.php') ) { |
|
| 487 | + if (is_file(get_stylesheet_directory() . '/admin/wpshop_elements_template.tpl.php')) { |
|
| 488 | 488 | require_once(get_stylesheet_directory() . '/admin/wpshop_elements_template.tpl.php'); |
| 489 | 489 | if (!empty($tpl_element)) |
| 490 | - $wpshop_template['admin']['custom'] = ($tpl_element);unset($tpl_element); |
|
| 490 | + $wpshop_template['admin']['custom'] = ($tpl_element); unset($tpl_element); |
|
| 491 | 491 | } |
| 492 | 492 | /* Get default frontend template */ |
| 493 | 493 | require_once(WPSHOP_TEMPLATES_DIR . 'wpshop/main_elements.tpl.php'); |
| 494 | - $wpshop_template['wpshop']['default'] = ($tpl_element);unset($tpl_element); |
|
| 494 | + $wpshop_template['wpshop']['default'] = ($tpl_element); unset($tpl_element); |
|
| 495 | 495 | /* Get custom frontend template */ |
| 496 | - if ( is_file(get_stylesheet_directory() . '/wpshop/main_elements.tpl.php') ) { |
|
| 496 | + if (is_file(get_stylesheet_directory() . '/wpshop/main_elements.tpl.php')) { |
|
| 497 | 497 | require_once(get_stylesheet_directory() . '/wpshop/main_elements.tpl.php'); |
| 498 | 498 | if (!empty($tpl_element)) |
| 499 | - $wpshop_template['wpshop']['custom'] = ($tpl_element);unset($tpl_element); |
|
| 499 | + $wpshop_template['wpshop']['custom'] = ($tpl_element); unset($tpl_element); |
|
| 500 | 500 | } |
| 501 | - if ( is_file(get_stylesheet_directory() . '/wpshop/wpshop_elements_template.tpl.php') ) { |
|
| 501 | + if (is_file(get_stylesheet_directory() . '/wpshop/wpshop_elements_template.tpl.php')) { |
|
| 502 | 502 | require_once(get_stylesheet_directory() . '/wpshop/wpshop_elements_template.tpl.php'); |
| 503 | 503 | if (!empty($tpl_element)) |
| 504 | - $wpshop_template['wpshop']['custom'] = ($tpl_element);unset($tpl_element); |
|
| 504 | + $wpshop_template['wpshop']['custom'] = ($tpl_element); unset($tpl_element); |
|
| 505 | 505 | } |
| 506 | - foreach ( $wpshop_template as $site_side => $types ) { |
|
| 507 | - foreach ( $types as $type => $tpl_component ) { |
|
| 508 | - foreach ( $tpl_component as $tpl_key => $tpl_content ) { |
|
| 506 | + foreach ($wpshop_template as $site_side => $types) { |
|
| 507 | + foreach ($types as $type => $tpl_component) { |
|
| 508 | + foreach ($tpl_component as $tpl_key => $tpl_content) { |
|
| 509 | 509 | $wpshop_template[$site_side][$type][$tpl_key] = str_replace(" |
| 510 | 510 | ", '', $tpl_content); |
| 511 | 511 | } |
| 512 | 512 | } |
| 513 | 513 | } |
| 514 | 514 | |
| 515 | - $wpshop_template = apply_filters( 'wpshop_custom_template', $wpshop_template); |
|
| 515 | + $wpshop_template = apply_filters('wpshop_custom_template', $wpshop_template); |
|
| 516 | 516 | |
| 517 | - DEFINE( 'WPSHOP_TEMPLATE', serialize($wpshop_template) ); |
|
| 517 | + DEFINE('WPSHOP_TEMPLATE', serialize($wpshop_template)); |
|
| 518 | 518 | } |
| 519 | 519 | |
| 520 | 520 | /** |
@@ -525,12 +525,12 @@ discard block |
||
| 525 | 525 | * |
| 526 | 526 | * @return array The new array with all elment, internal and module templates |
| 527 | 527 | */ |
| 528 | - public static function add_modules_template_to_internal( $tpl_element, $templates ) { |
|
| 529 | - if ( !empty($tpl_element) ) { |
|
| 530 | - foreach ( $tpl_element as $template_part => $template_part_content) { |
|
| 531 | - if ( !empty($template_part_content) && is_array($template_part_content) ) { |
|
| 532 | - foreach ( $template_part_content as $template_type => $template_type_content) { |
|
| 533 | - foreach ( $template_type_content as $template_key => $template) { |
|
| 528 | + public static function add_modules_template_to_internal($tpl_element, $templates) { |
|
| 529 | + if (!empty($tpl_element)) { |
|
| 530 | + foreach ($tpl_element as $template_part => $template_part_content) { |
|
| 531 | + if (!empty($template_part_content) && is_array($template_part_content)) { |
|
| 532 | + foreach ($template_part_content as $template_type => $template_type_content) { |
|
| 533 | + foreach ($template_type_content as $template_key => $template) { |
|
| 534 | 534 | $templates[$template_part][$template_type][$template_key] = $template; |
| 535 | 535 | } |
| 536 | 536 | } |
@@ -550,20 +550,20 @@ discard block |
||
| 550 | 550 | * |
| 551 | 551 | * @return string The good template to take in care, regarding on the given parameters |
| 552 | 552 | */ |
| 553 | - public static function check_template_to_display( $part, $template_part, $extras_args, $default_template_dir ) { |
|
| 553 | + public static function check_template_to_display($part, $template_part, $extras_args, $default_template_dir) { |
|
| 554 | 554 | $tpl_element_to_return = ''; |
| 555 | 555 | |
| 556 | 556 | /** Get the defined template */ |
| 557 | 557 | $template = defined("WPSHOP_TEMPLATE") ? unserialize(WPSHOP_TEMPLATE) : array(); |
| 558 | 558 | |
| 559 | - if ( !empty($extras_args['type']) && !empty($extras_args['id']) && !empty( $template[$default_template_dir][$part]) && !empty($extras_args['page']) && !empty( $template[$default_template_dir][$part][$extras_args['page']] ) && !empty( $template[$default_template_dir][$part][$extras_args['page']][$extras_args['type']]) && !empty( $template[$default_template_dir][$part][$extras_args['page']][$extras_args['type']][$extras_args['id']] ) && !empty( $template[$default_template_dir][$part][$extras_args['page']][$extras_args['type']][$extras_args['id']][$template_part] ) ) { |
|
| 559 | + if (!empty($extras_args['type']) && !empty($extras_args['id']) && !empty($template[$default_template_dir][$part]) && !empty($extras_args['page']) && !empty($template[$default_template_dir][$part][$extras_args['page']]) && !empty($template[$default_template_dir][$part][$extras_args['page']][$extras_args['type']]) && !empty($template[$default_template_dir][$part][$extras_args['page']][$extras_args['type']][$extras_args['id']]) && !empty($template[$default_template_dir][$part][$extras_args['page']][$extras_args['type']][$extras_args['id']][$template_part])) { |
|
| 560 | 560 | $tpl_element_to_return = $template[$default_template_dir][$part][$extras_args['page']][$extras_args['type']][$extras_args['id']][$template_part]; |
| 561 | 561 | } |
| 562 | - elseif ( !empty($extras_args['type']) && !empty($extras_args['id']) && !empty( $template[$default_template_dir][$part][$extras_args['type']]) && !empty( $template[$default_template_dir][$part][$extras_args['type']][$extras_args['id']] ) && !empty( $template[$default_template_dir][$part][$extras_args['type']][$extras_args['id']][$template_part] ) ) { |
|
| 562 | + elseif (!empty($extras_args['type']) && !empty($extras_args['id']) && !empty($template[$default_template_dir][$part][$extras_args['type']]) && !empty($template[$default_template_dir][$part][$extras_args['type']][$extras_args['id']]) && !empty($template[$default_template_dir][$part][$extras_args['type']][$extras_args['id']][$template_part])) { |
|
| 563 | 563 | $tpl_element_to_return = $template[$default_template_dir][$part][$extras_args['type']][$extras_args['id']][$template_part]; |
| 564 | 564 | } |
| 565 | 565 | /** Check if the file have been duplicated into theme directory for customization */ |
| 566 | - elseif ( !empty( $template[$default_template_dir][$part] ) && !empty( $template[$default_template_dir][$part][$template_part] ) ) { |
|
| 566 | + elseif (!empty($template[$default_template_dir][$part]) && !empty($template[$default_template_dir][$part][$template_part])) { |
|
| 567 | 567 | $tpl_element_to_return = $template[$default_template_dir][$part][$template_part]; |
| 568 | 568 | } |
| 569 | 569 | |
@@ -583,13 +583,13 @@ discard block |
||
| 583 | 583 | $feed['CURRENCY'] = wpshop_tools::wpshop_get_currency(); |
| 584 | 584 | $feed['CURRENCY_CHOOSEN'] = wpshop_tools::wpshop_get_currency(); |
| 585 | 585 | $feed['CURRENCY_SELECTOR'] = wpshop_attributes_unit::wpshop_shop_currency_list_field(); |
| 586 | - $feed['CART_LINK'] = get_permalink( wpshop_tools::get_page_id( get_option('wpshop_cart_page_id') ) ); |
|
| 586 | + $feed['CART_LINK'] = get_permalink(wpshop_tools::get_page_id(get_option('wpshop_cart_page_id'))); |
|
| 587 | 587 | |
| 588 | 588 | $available_key = array(); |
| 589 | 589 | foreach ($feed as $element => $value) { |
| 590 | - $available_key[] = '{WPSHOP_'.$element.'}'; |
|
| 591 | - if ( !is_array($value) ) { |
|
| 592 | - $template_to_fill = str_replace('{WPSHOP_'.$element.'}', $value, $template_to_fill); |
|
| 590 | + $available_key[] = '{WPSHOP_' . $element . '}'; |
|
| 591 | + if (!is_array($value)) { |
|
| 592 | + $template_to_fill = str_replace('{WPSHOP_' . $element . '}', $value, $template_to_fill); |
|
| 593 | 593 | } |
| 594 | 594 | } |
| 595 | 595 | if (WPSHOP_DISPLAY_AVAILABLE_KEYS_FOR_TEMPLATE) $template_to_fill = '<!-- Available keys : ' . implode(' / ', $available_key) . ' -->' . $template_to_fill; |
@@ -602,11 +602,11 @@ discard block |
||
| 602 | 602 | * |
| 603 | 603 | * @param boolean $force_replacement Define if we overwrite in all case or just if it not exist |
| 604 | 604 | */ |
| 605 | - public static function check_template_file( $force_replacement = false ) { |
|
| 605 | + public static function check_template_file($force_replacement = false) { |
|
| 606 | 606 | $wpshop_directory = get_stylesheet_directory() . '/wpshop'; |
| 607 | 607 | |
| 608 | 608 | /* Add different file template */ |
| 609 | - if(!is_dir($wpshop_directory)){ |
|
| 609 | + if (!is_dir($wpshop_directory)) { |
|
| 610 | 610 | @mkdir($wpshop_directory, 0755, true); |
| 611 | 611 | } |
| 612 | 612 | /* On s'assure que le dossier principal est bien en 0755 */ |
@@ -614,12 +614,12 @@ discard block |
||
| 614 | 614 | $upload_dir = wp_upload_dir(); |
| 615 | 615 | |
| 616 | 616 | /* Add the category template */ |
| 617 | - if(!is_file(get_stylesheet_directory() . '/taxonomy-wpshop_product_category.php') || ($force_replacement)){ |
|
| 617 | + if (!is_file(get_stylesheet_directory() . '/taxonomy-wpshop_product_category.php') || ($force_replacement)) { |
|
| 618 | 618 | @copy(WPSHOP_TEMPLATES_DIR . 'taxonomy-wpshop_product_category.php', get_stylesheet_directory() . '/taxonomy-wpshop_product_category.php'); |
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | /* Add the product template */ |
| 622 | - if(!is_file(get_stylesheet_directory() . '/single-wpshop_product.php') || ($force_replacement)){ |
|
| 622 | + if (!is_file(get_stylesheet_directory() . '/single-wpshop_product.php') || ($force_replacement)) { |
|
| 623 | 623 | @copy(WPSHOP_TEMPLATES_DIR . 'single-wpshop_product.php', get_stylesheet_directory() . '/single-wpshop_product.php'); |
| 624 | 624 | } |
| 625 | 625 | } |
@@ -637,31 +637,31 @@ discard block |
||
| 637 | 637 | /* Check if user is on taxonomy edition page */ |
| 638 | 638 | if ($pagenow == 'edit-tags.php') { |
| 639 | 639 | |
| 640 | - if(!user_can_richedit()) { return; } |
|
| 640 | + if (!user_can_richedit()) { return; } |
|
| 641 | 641 | |
| 642 | 642 | $taxonomies = get_taxonomies(); |
| 643 | 643 | |
| 644 | 644 | foreach ($taxonomies as $tax) { |
| 645 | - if ( in_array($tax, array(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES)) ) { |
|
| 646 | - add_action($tax . '_edit_form_fields', array('wpshop_display','wpshop_add_form')); |
|
| 647 | - add_action($tax . '_add_form_fields', array('wpshop_display','wpshop_add_form')); |
|
| 645 | + if (in_array($tax, array(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES))) { |
|
| 646 | + add_action($tax . '_edit_form_fields', array('wpshop_display', 'wpshop_add_form')); |
|
| 647 | + add_action($tax . '_add_form_fields', array('wpshop_display', 'wpshop_add_form')); |
|
| 648 | 648 | } |
| 649 | 649 | } |
| 650 | - $action = !empty( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action'] ) : ''; |
|
| 651 | - $taxonomy = !empty( $_REQUEST['taxonomy'] ) ? sanitize_text_field( $_REQUEST['taxonomy'] ) : ''; |
|
| 650 | + $action = !empty($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : ''; |
|
| 651 | + $taxonomy = !empty($_REQUEST['taxonomy']) ? sanitize_text_field($_REQUEST['taxonomy']) : ''; |
|
| 652 | 652 | |
| 653 | 653 | if ($pagenow == 'edit-tags.php' && isset($action) && $action == 'edit' && empty($taxonomy)) { |
| 654 | - add_action('edit_term',array('wpshop_display','wpshop_rt_taxonomy_save')); |
|
| 654 | + add_action('edit_term', array('wpshop_display', 'wpshop_rt_taxonomy_save')); |
|
| 655 | 655 | } |
| 656 | 656 | |
| 657 | - foreach ( array( 'pre_term_description', 'pre_link_description', 'pre_link_notes', 'pre_user_description' ) as $filter ) { |
|
| 658 | - remove_filter( $filter, 'wp_filter_kses' ); |
|
| 657 | + foreach (array('pre_term_description', 'pre_link_description', 'pre_link_notes', 'pre_user_description') as $filter) { |
|
| 658 | + remove_filter($filter, 'wp_filter_kses'); |
|
| 659 | 659 | } |
| 660 | 660 | |
| 661 | 661 | } |
| 662 | 662 | |
| 663 | 663 | /* Enable shortcodes in category, taxonomy, tag descriptions */ |
| 664 | - if(function_exists('term_description')) { |
|
| 664 | + if (function_exists('term_description')) { |
|
| 665 | 665 | add_filter('term_description', 'do_shortcode'); |
| 666 | 666 | } |
| 667 | 667 | else { |
@@ -677,8 +677,8 @@ discard block |
||
| 677 | 677 | |
| 678 | 678 | $a = array('description'); |
| 679 | 679 | foreach ($a as $v) { |
| 680 | - $term = (array) $_POST[$v]; |
|
| 681 | - wp_update_term($tag_ID,$v,$term); |
|
| 680 | + $term = (array)$_POST[$v]; |
|
| 681 | + wp_update_term($tag_ID, $v, $term); |
|
| 682 | 682 | } |
| 683 | 683 | } |
| 684 | 684 | |
@@ -690,9 +690,9 @@ discard block |
||
| 690 | 690 | public static function wpshop_add_form($object = '') { |
| 691 | 691 | global $pagenow; |
| 692 | 692 | |
| 693 | - $content = is_object($object) && isset($object->description) ? ( html_entity_decode( $object->description, ENT_COMPAT | ENT_HTML401, 'UTF-8' ) ) : ''; |
|
| 693 | + $content = is_object($object) && isset($object->description) ? (html_entity_decode($object->description, ENT_COMPAT | ENT_HTML401, 'UTF-8')) : ''; |
|
| 694 | 694 | |
| 695 | - if( in_array($pagenow, array('edit-tags.php')) ) { |
|
| 695 | + if (in_array($pagenow, array('edit-tags.php'))) { |
|
| 696 | 696 | $editor_id = 'tag_description'; |
| 697 | 697 | $editor_selector = 'description'; |
| 698 | 698 | } |
@@ -722,8 +722,8 @@ discard block |
||
| 722 | 722 | |
| 723 | 723 | public static function wps_hide_admin_bar_for_customers() { |
| 724 | 724 | $wpshop_hide_admin_bar_option = get_option('wpshop_display_option'); |
| 725 | - if ( !empty($wpshop_hide_admin_bar_option) && !empty($wpshop_hide_admin_bar_option['wpshop_hide_admin_bar']) && ! current_user_can( 'manage_options' ) ) { |
|
| 726 | - show_admin_bar( false ); |
|
| 725 | + if (!empty($wpshop_hide_admin_bar_option) && !empty($wpshop_hide_admin_bar_option['wpshop_hide_admin_bar']) && !current_user_can('manage_options')) { |
|
| 726 | + show_admin_bar(false); |
|
| 727 | 727 | } |
| 728 | 728 | } |
| 729 | 729 | |
@@ -737,7 +737,7 @@ discard block |
||
| 737 | 737 | * @param string $content The content of a post |
| 738 | 738 | * @return Ambigous <mixed, string>|unknown |
| 739 | 739 | */ |
| 740 | - public static function products_page( $content = '' ) { |
|
| 740 | + public static function products_page($content = '') { |
|
| 741 | 741 | global $wp_query; |
| 742 | 742 | |
| 743 | 743 | if (!empty($wp_query->queried_object) && !empty($wp_query->queried_object->post_type) && ($wp_query->queried_object->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT)) { |
@@ -756,15 +756,15 @@ discard block |
||
| 756 | 756 | * |
| 757 | 757 | * @return string The formated value |
| 758 | 758 | */ |
| 759 | - public static function format_field_output( $output_type, $value ) { |
|
| 759 | + public static function format_field_output($output_type, $value) { |
|
| 760 | 760 | $formated_value = $value; |
| 761 | 761 | |
| 762 | - if ( !empty($value) ) { |
|
| 763 | - switch ( $output_type ) { |
|
| 762 | + if (!empty($value)) { |
|
| 763 | + switch ($output_type) { |
|
| 764 | 764 | case 'wpshop_product_price': |
| 765 | - $formated_value = (is_numeric($value) ) ? number_format($value, 2, ',', '') : $value; |
|
| 765 | + $formated_value = (is_numeric($value)) ? number_format($value, 2, ',', '') : $value; |
|
| 766 | 766 | $formated_value_content = explode(',', $formated_value); |
| 767 | - if ( !empty($formated_value_content) && !empty($formated_value_content[1]) && $formated_value_content[1] <= 0 ) { |
|
| 767 | + if (!empty($formated_value_content) && !empty($formated_value_content[1]) && $formated_value_content[1] <= 0) { |
|
| 768 | 768 | $formated_value = $formated_value_content[0]; |
| 769 | 769 | } |
| 770 | 770 | break; |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * @param string $method The default method for the form Default is set to post |
| 31 | 31 | * @param string $action The default action for the form Default is set to empty |
| 32 | 32 | * |
| 33 | - * @return mixed $the_form The complete html output of the form |
|
| 33 | + * @return string $the_form The complete html output of the form |
|
| 34 | 34 | */ |
| 35 | 35 | function form($name, $input_list, $method = 'post', $action = ''){ |
| 36 | 36 | $the_form_content_hidden = $the_form_content = ''; |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | * @param string $type The input type Could be: text or hidden or passowrd |
| 130 | 130 | * @param string $option Allows to define options for the input Could be readonly or disabled or style |
| 131 | 131 | * |
| 132 | - * @return mixed The output code to add to the form |
|
| 132 | + * @return string The output code to add to the form |
|
| 133 | 133 | */ |
| 134 | 134 | public static function form_input($name, $id, $value = '', $type = 'text', $option = '', $input_label = ''){ |
| 135 | 135 | $allowedType = array('text', 'hidden', 'password', 'file'); |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | * @param mixed $value The default value for the field Default is empty |
| 153 | 153 | * @param string $option Allows to define options for the input Could be maxlength or style |
| 154 | 154 | * |
| 155 | - * @return mixed The output code to add to the form |
|
| 155 | + * @return string The output code to add to the form |
|
| 156 | 156 | */ |
| 157 | 157 | public static function form_input_textarea($name, $id, $value = '', $option = '') |
| 158 | 158 | { |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | * @param mixed $value The selected value for the field Default is empty |
| 168 | 168 | * @param string $option Allows to define options for the input Could be onchange |
| 169 | 169 | * |
| 170 | - * @return mixed $output The output code to add to the form |
|
| 170 | + * @return string $output The output code to add to the form |
|
| 171 | 171 | */ |
| 172 | 172 | public static function form_input_select($name, $id, $content, $value = '', $option = '', $optionValue = ''){ |
| 173 | 173 | global $comboxOptionToHide; |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | * @param mixed $value The selected value for the field Default is empty |
| 216 | 216 | * @param string $option Allows to define options for the input Could be onchange |
| 217 | 217 | * |
| 218 | - * @return mixed $output The output code to add to the form |
|
| 218 | + * @return string $output The output code to add to the form |
|
| 219 | 219 | */ |
| 220 | 220 | public static function form_input_multiple_select($name, $id, $content, $value = array(), $option = '', $optionValue = '') { |
| 221 | 221 | global $comboxOptionToHide; |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | * @param mixed $value The selected value for the field Default is empty |
| 259 | 259 | * @param string $option Allows to define options for the input Could be onchange |
| 260 | 260 | * |
| 261 | - * @return mixed $output The output code to add to the form |
|
| 261 | + * @return string $output The output code to add to the form |
|
| 262 | 262 | */ |
| 263 | 263 | public static function form_input_check($name, $id, $content, $value = '', $type = 'checkbox', $option = '', $optionValue = '', $input_label=''){ |
| 264 | 264 | $output = ''; |
@@ -23,15 +23,15 @@ discard block |
||
| 23 | 23 | class wpshop_form { |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | - * Create The complete form by defining the form open and close and call the different function that allows to create the different type of input |
|
| 27 | - * |
|
| 28 | - * @param string $name The name of the form |
|
| 29 | - * @param array $input_list The list build by the database class' function that get the type of a table |
|
| 30 | - * @param string $method The default method for the form Default is set to post |
|
| 31 | - * @param string $action The default action for the form Default is set to empty |
|
| 32 | - * |
|
| 33 | - * @return mixed $the_form The complete html output of the form |
|
| 34 | - */ |
|
| 26 | + * Create The complete form by defining the form open and close and call the different function that allows to create the different type of input |
|
| 27 | + * |
|
| 28 | + * @param string $name The name of the form |
|
| 29 | + * @param array $input_list The list build by the database class' function that get the type of a table |
|
| 30 | + * @param string $method The default method for the form Default is set to post |
|
| 31 | + * @param string $action The default action for the form Default is set to empty |
|
| 32 | + * |
|
| 33 | + * @return mixed $the_form The complete html output of the form |
|
| 34 | + */ |
|
| 35 | 35 | function form($name, $input_list, $method = 'post', $action = ''){ |
| 36 | 36 | $the_form_content_hidden = $the_form_content = ''; |
| 37 | 37 | foreach ($input_list as $input_key => $input_def) { |
@@ -68,12 +68,12 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | - * Check the input type |
|
| 72 | - * |
|
| 73 | - * @param array $input_def The input definition |
|
| 74 | - * |
|
| 75 | - * @return string $the_input |
|
| 76 | - */ |
|
| 71 | + * Check the input type |
|
| 72 | + * |
|
| 73 | + * @param array $input_def The input definition |
|
| 74 | + * |
|
| 75 | + * @return string $the_input |
|
| 76 | + */ |
|
| 77 | 77 | public static function check_input_type($input_def, $input_domain = '') { |
| 78 | 78 | |
| 79 | 79 | $input_option = ''; |
@@ -122,15 +122,15 @@ discard block |
||
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /** |
| 125 | - * Create an input type text or hidden or password |
|
| 126 | - * |
|
| 127 | - * @param string $name The name of the field given by the database |
|
| 128 | - * @param mixed $value The default value for the field Default is empty |
|
| 129 | - * @param string $type The input type Could be: text or hidden or passowrd |
|
| 130 | - * @param string $option Allows to define options for the input Could be readonly or disabled or style |
|
| 131 | - * |
|
| 132 | - * @return mixed The output code to add to the form |
|
| 133 | - */ |
|
| 125 | + * Create an input type text or hidden or password |
|
| 126 | + * |
|
| 127 | + * @param string $name The name of the field given by the database |
|
| 128 | + * @param mixed $value The default value for the field Default is empty |
|
| 129 | + * @param string $type The input type Could be: text or hidden or passowrd |
|
| 130 | + * @param string $option Allows to define options for the input Could be readonly or disabled or style |
|
| 131 | + * |
|
| 132 | + * @return mixed The output code to add to the form |
|
| 133 | + */ |
|
| 134 | 134 | public static function form_input($name, $id, $value = '', $type = 'text', $option = '', $input_label = ''){ |
| 135 | 135 | $allowedType = array('text', 'hidden', 'password', 'file'); |
| 136 | 136 | if(in_array($type, $allowedType)) |
@@ -146,29 +146,29 @@ discard block |
||
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
| 149 | - * Create an textarea |
|
| 150 | - * |
|
| 151 | - * @param string $name The name of the field given by the database |
|
| 152 | - * @param mixed $value The default value for the field Default is empty |
|
| 153 | - * @param string $option Allows to define options for the input Could be maxlength or style |
|
| 154 | - * |
|
| 155 | - * @return mixed The output code to add to the form |
|
| 156 | - */ |
|
| 149 | + * Create an textarea |
|
| 150 | + * |
|
| 151 | + * @param string $name The name of the field given by the database |
|
| 152 | + * @param mixed $value The default value for the field Default is empty |
|
| 153 | + * @param string $option Allows to define options for the input Could be maxlength or style |
|
| 154 | + * |
|
| 155 | + * @return mixed The output code to add to the form |
|
| 156 | + */ |
|
| 157 | 157 | public static function form_input_textarea($name, $id, $value = '', $option = '') |
| 158 | 158 | { |
| 159 | 159 | return '<textarea name="' . $name.'" id="' . $id . '" ' . $option . ' rows="4" cols="10" >' . $value . '</textarea>'; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
| 163 | - * Create a combo box input regarding to the type of content given in parameters could be an array or a wordpress database object |
|
| 164 | - * |
|
| 165 | - * @param string $name The name of the field given by the database |
|
| 166 | - * @param mixed $content The list of element to put inot the combo box Could be an array or a wordpress database object with id and nom as field |
|
| 167 | - * @param mixed $value The selected value for the field Default is empty |
|
| 168 | - * @param string $option Allows to define options for the input Could be onchange |
|
| 169 | - * |
|
| 170 | - * @return mixed $output The output code to add to the form |
|
| 171 | - */ |
|
| 163 | + * Create a combo box input regarding to the type of content given in parameters could be an array or a wordpress database object |
|
| 164 | + * |
|
| 165 | + * @param string $name The name of the field given by the database |
|
| 166 | + * @param mixed $content The list of element to put inot the combo box Could be an array or a wordpress database object with id and nom as field |
|
| 167 | + * @param mixed $value The selected value for the field Default is empty |
|
| 168 | + * @param string $option Allows to define options for the input Could be onchange |
|
| 169 | + * |
|
| 170 | + * @return mixed $output The output code to add to the form |
|
| 171 | + */ |
|
| 172 | 172 | public static function form_input_select($name, $id, $content, $value = '', $option = '', $optionValue = ''){ |
| 173 | 173 | global $comboxOptionToHide; |
| 174 | 174 | |
@@ -208,15 +208,15 @@ discard block |
||
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | /** |
| 211 | - * Create a combo box input regarding to the type of content given in parameters could be an array or a wordpress database object |
|
| 212 | - * |
|
| 213 | - * @param string $name The name of the field given by the database |
|
| 214 | - * @param mixed $content The list of element to put inot the combo box Could be an array or a wordpress database object with id and nom as field |
|
| 215 | - * @param mixed $value The selected value for the field Default is empty |
|
| 216 | - * @param string $option Allows to define options for the input Could be onchange |
|
| 217 | - * |
|
| 218 | - * @return mixed $output The output code to add to the form |
|
| 219 | - */ |
|
| 211 | + * Create a combo box input regarding to the type of content given in parameters could be an array or a wordpress database object |
|
| 212 | + * |
|
| 213 | + * @param string $name The name of the field given by the database |
|
| 214 | + * @param mixed $content The list of element to put inot the combo box Could be an array or a wordpress database object with id and nom as field |
|
| 215 | + * @param mixed $value The selected value for the field Default is empty |
|
| 216 | + * @param string $option Allows to define options for the input Could be onchange |
|
| 217 | + * |
|
| 218 | + * @return mixed $output The output code to add to the form |
|
| 219 | + */ |
|
| 220 | 220 | public static function form_input_multiple_select($name, $id, $content, $value = array(), $option = '', $optionValue = '') { |
| 221 | 221 | global $comboxOptionToHide; |
| 222 | 222 | $values = array(); |
@@ -249,17 +249,17 @@ discard block |
||
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | /** |
| 252 | - * Create a checkbox input |
|
| 253 | - * |
|
| 254 | - * @param string $name The name of the field given by the database |
|
| 255 | - * @param string $id The identifier of the field |
|
| 256 | - * @param string $type The input type Could be checkbox or radio |
|
| 257 | - * @param mixed $content The list of element to put inot the combo box Could be an array or a wordpress database object with id and nom as field |
|
| 258 | - * @param mixed $value The selected value for the field Default is empty |
|
| 259 | - * @param string $option Allows to define options for the input Could be onchange |
|
| 260 | - * |
|
| 261 | - * @return mixed $output The output code to add to the form |
|
| 262 | - */ |
|
| 252 | + * Create a checkbox input |
|
| 253 | + * |
|
| 254 | + * @param string $name The name of the field given by the database |
|
| 255 | + * @param string $id The identifier of the field |
|
| 256 | + * @param string $type The input type Could be checkbox or radio |
|
| 257 | + * @param mixed $content The list of element to put inot the combo box Could be an array or a wordpress database object with id and nom as field |
|
| 258 | + * @param mixed $value The selected value for the field Default is empty |
|
| 259 | + * @param string $option Allows to define options for the input Could be onchange |
|
| 260 | + * |
|
| 261 | + * @return mixed $output The output code to add to the form |
|
| 262 | + */ |
|
| 263 | 263 | public static function form_input_check($name, $id, $content, $value = '', $type = 'checkbox', $option = '', $optionValue = '', $input_label=''){ |
| 264 | 264 | $output = ''; |
| 265 | 265 | $allowedType = array('checkbox', 'radio'); |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | |
| 3 | 3 | /* Check if file is include. No direct access possible with file url */ |
| 4 | -if ( !defined( 'WPSHOP_VERSION' ) ) { |
|
| 5 | - die( __('Access is not allowed by this way', 'wpshop') ); |
|
| 4 | +if (!defined('WPSHOP_VERSION')) { |
|
| 5 | + die(__('Access is not allowed by this way', 'wpshop')); |
|
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | /** |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @return mixed $the_form The complete html output of the form |
| 34 | 34 | */ |
| 35 | - function form($name, $input_list, $method = 'post', $action = ''){ |
|
| 35 | + function form($name, $input_list, $method = 'post', $action = '') { |
|
| 36 | 36 | $the_form_content_hidden = $the_form_content = ''; |
| 37 | 37 | foreach ($input_list as $input_key => $input_def) { |
| 38 | 38 | $the_input = self::check_input_type($input_def); |
@@ -40,10 +40,10 @@ discard block |
||
| 40 | 40 | $input_value = $input_def['value']; |
| 41 | 41 | $input_type = $input_def['type']; |
| 42 | 42 | |
| 43 | - if($input_type != 'hidden') |
|
| 43 | + if ($input_type != 'hidden') |
|
| 44 | 44 | { |
| 45 | 45 | $label = 'for="' . $input_name . '"'; |
| 46 | - if(($input_type == 'radio') || ($input_type == 'checkbox')) |
|
| 46 | + if (($input_type == 'radio') || ($input_type == 'checkbox')) |
|
| 47 | 47 | { |
| 48 | 48 | $label = ''; |
| 49 | 49 | } |
@@ -77,45 +77,45 @@ discard block |
||
| 77 | 77 | public static function check_input_type($input_def, $input_domain = '') { |
| 78 | 78 | |
| 79 | 79 | $input_option = ''; |
| 80 | - if(!empty($input_def['option']) && $input_def['option']) |
|
| 80 | + if (!empty($input_def['option']) && $input_def['option']) |
|
| 81 | 81 | $input_option = $input_def['option']; |
| 82 | 82 | |
| 83 | 83 | $valueToPut = ''; |
| 84 | - if(!empty($input_def['valueToPut']) && $input_def['valueToPut']) |
|
| 84 | + if (!empty($input_def['valueToPut']) && $input_def['valueToPut']) |
|
| 85 | 85 | $valueToPut = $input_def['valueToPut']; |
| 86 | 86 | |
| 87 | 87 | $input_id = $input_def['name']; |
| 88 | - if(!empty($input_def['id'])) |
|
| 88 | + if (!empty($input_def['id'])) |
|
| 89 | 89 | $input_id = $input_def['id']; |
| 90 | 90 | |
| 91 | 91 | $input_name = $input_def['name']; |
| 92 | - if($input_domain != '') |
|
| 92 | + if ($input_domain != '') |
|
| 93 | 93 | $input_name = $input_domain . '[' . $input_def['name'] . ']'; |
| 94 | 94 | /** Format data for saving without special chars */ |
| 95 | - if(!empty($input_def['value']) && !is_array($input_def['value']) && preg_match("/^-?(?:\d+|\d*\.\d+)$/", $input_def['value'])) |
|
| 96 | - $input_value = str_replace('.',',',$input_def['value']/* /1 */); // format francais avec virgule |
|
| 95 | + if (!empty($input_def['value']) && !is_array($input_def['value']) && preg_match("/^-?(?:\d+|\d*\.\d+)$/", $input_def['value'])) |
|
| 96 | + $input_value = str_replace('.', ',', $input_def['value']/* /1 */); // format francais avec virgule |
|
| 97 | 97 | else $input_value = (!empty($input_def['value']) ? $input_def['value'] : ''); |
| 98 | 98 | |
| 99 | 99 | $input_type = $input_def['type']; |
| 100 | 100 | $the_input = ''; |
| 101 | 101 | |
| 102 | - if( ( $input_type == 'text' ) || ( $input_type == 'email' ) || ( $input_type == 'tel' ) ) |
|
| 103 | - $the_input .= self::form_input( $input_name, $input_id, $input_value, 'text', $input_option, (!empty($input_def['options_label']) ? $input_def['options_label'] : '') ); |
|
| 104 | - elseif($input_type == 'password') |
|
| 102 | + if (($input_type == 'text') || ($input_type == 'email') || ($input_type == 'tel')) |
|
| 103 | + $the_input .= self::form_input($input_name, $input_id, $input_value, 'text', $input_option, (!empty($input_def['options_label']) ? $input_def['options_label'] : '')); |
|
| 104 | + elseif ($input_type == 'password') |
|
| 105 | 105 | $the_input .= self::form_input($input_name, $input_id, $input_value, 'password', $input_option); |
| 106 | - elseif($input_type == 'textarea') |
|
| 106 | + elseif ($input_type == 'textarea') |
|
| 107 | 107 | $the_input .= self::form_input_textarea($input_name, $input_id, $input_value, $input_option); |
| 108 | - elseif($input_type == 'hidden') |
|
| 108 | + elseif ($input_type == 'hidden') |
|
| 109 | 109 | $the_input .= self::form_input($input_name, $input_id, $input_value, 'hidden', $input_option); |
| 110 | - elseif($input_type == 'select') |
|
| 111 | - $the_input .= self::form_input_select($input_name, $input_id, ( !empty($input_def['possible_value']) ? $input_def['possible_value'] : array() ), $input_value, $input_option, $valueToPut); |
|
| 112 | - elseif($input_type == 'multiple-select') |
|
| 113 | - $the_input .= self::form_input_multiple_select($input_name, $input_id, ( !empty($input_def['possible_value']) ? $input_def['possible_value'] : array() ), $input_value, $input_option, $valueToPut); |
|
| 114 | - elseif(($input_type == 'radio') || ($input_type == 'checkbox')) |
|
| 115 | - $the_input .= self::form_input_check($input_name, $input_id, ( !empty($input_def['possible_value']) ? $input_def['possible_value'] : array() ), $input_value, $input_type, $input_option, $valueToPut, (!empty($input_def['options_label']) ? $input_def['options_label'] : '')); |
|
| 116 | - elseif($input_type == 'file') |
|
| 110 | + elseif ($input_type == 'select') |
|
| 111 | + $the_input .= self::form_input_select($input_name, $input_id, (!empty($input_def['possible_value']) ? $input_def['possible_value'] : array()), $input_value, $input_option, $valueToPut); |
|
| 112 | + elseif ($input_type == 'multiple-select') |
|
| 113 | + $the_input .= self::form_input_multiple_select($input_name, $input_id, (!empty($input_def['possible_value']) ? $input_def['possible_value'] : array()), $input_value, $input_option, $valueToPut); |
|
| 114 | + elseif (($input_type == 'radio') || ($input_type == 'checkbox')) |
|
| 115 | + $the_input .= self::form_input_check($input_name, $input_id, (!empty($input_def['possible_value']) ? $input_def['possible_value'] : array()), $input_value, $input_type, $input_option, $valueToPut, (!empty($input_def['options_label']) ? $input_def['options_label'] : '')); |
|
| 116 | + elseif ($input_type == 'file') |
|
| 117 | 117 | $the_input .= self::form_input($input_name, $input_id, $input_value, 'file', $input_option); |
| 118 | - elseif($input_type == 'gallery') |
|
| 118 | + elseif ($input_type == 'gallery') |
|
| 119 | 119 | $the_input .= self::form_input($input_name, $input_id, $input_value, 'text', 'readonly = "readonly"') . 'Gallery field to check'; |
| 120 | 120 | |
| 121 | 121 | return $the_input; |
@@ -131,17 +131,17 @@ discard block |
||
| 131 | 131 | * |
| 132 | 132 | * @return mixed The output code to add to the form |
| 133 | 133 | */ |
| 134 | - public static function form_input($name, $id, $value = '', $type = 'text', $option = '', $input_label = ''){ |
|
| 134 | + public static function form_input($name, $id, $value = '', $type = 'text', $option = '', $input_label = '') { |
|
| 135 | 135 | $allowedType = array('text', 'hidden', 'password', 'file'); |
| 136 | - if(in_array($type, $allowedType)) |
|
| 136 | + if (in_array($type, $allowedType)) |
|
| 137 | 137 | { |
| 138 | - $output = '<input type="' . $type . '" name="' . $name . '" id="' . $id . '" value="' . $value . '" ' . $option . ' />' ; |
|
| 138 | + $output = '<input type="' . $type . '" name="' . $name . '" id="' . $id . '" value="' . $value . '" ' . $option . ' />'; |
|
| 139 | 139 | } |
| 140 | 140 | else |
| 141 | 141 | { |
| 142 | 142 | return sprintf(__('Input type not allowed here in %s at line %s', 'wpshop'), __FILE__, __LINE__); |
| 143 | 143 | } |
| 144 | - $output.=(is_array($input_label) && !empty($input_label['custom']) ? '<label for="' . $id . '">'.$input_label['custom'].'</label> ':''); |
|
| 144 | + $output .= (is_array($input_label) && !empty($input_label['custom']) ? '<label for="' . $id . '">' . $input_label['custom'] . '</label> ' : ''); |
|
| 145 | 145 | return $output; |
| 146 | 146 | } |
| 147 | 147 | |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | */ |
| 157 | 157 | public static function form_input_textarea($name, $id, $value = '', $option = '') |
| 158 | 158 | { |
| 159 | - return '<textarea name="' . $name.'" id="' . $id . '" ' . $option . ' rows="4" cols="10" >' . $value . '</textarea>'; |
|
| 159 | + return '<textarea name="' . $name . '" id="' . $id . '" ' . $option . ' rows="4" cols="10" >' . $value . '</textarea>'; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -169,38 +169,38 @@ discard block |
||
| 169 | 169 | * |
| 170 | 170 | * @return mixed $output The output code to add to the form |
| 171 | 171 | */ |
| 172 | - public static function form_input_select($name, $id, $content, $value = '', $option = '', $optionValue = ''){ |
|
| 172 | + public static function form_input_select($name, $id, $content, $value = '', $option = '', $optionValue = '') { |
|
| 173 | 173 | global $comboxOptionToHide; |
| 174 | 174 | |
| 175 | 175 | $output = '<select id="' . $id . '" name="' . $name . '" ' . $option . ' data-placeholder="' . __('Select an Option', 'wpshop') . '" >'; |
| 176 | 176 | |
| 177 | - if(is_array($content) && (count($content) > 0)){ |
|
| 178 | - foreach($content as $index => $datas){ |
|
| 179 | - if(is_object($datas) && (!is_array($comboxOptionToHide) || !in_array($datas->id, $comboxOptionToHide))){ |
|
| 177 | + if (is_array($content) && (count($content) > 0)) { |
|
| 178 | + foreach ($content as $index => $datas) { |
|
| 179 | + if (is_object($datas) && (!is_array($comboxOptionToHide) || !in_array($datas->id, $comboxOptionToHide))) { |
|
| 180 | 180 | |
| 181 | 181 | $selected = ($value == $datas->id) ? ' selected="selected" ' : ''; |
| 182 | 182 | |
| 183 | - $dataText = __('Nothing to output' ,'wpshop'); |
|
| 184 | - if(isset($datas->name)) |
|
| 185 | - $dataText = __($datas->name ,'wpshop'); |
|
| 186 | - elseif(isset($datas->code)) |
|
| 187 | - $dataText = __($datas->code ,'wpshop'); |
|
| 183 | + $dataText = __('Nothing to output', 'wpshop'); |
|
| 184 | + if (isset($datas->name)) |
|
| 185 | + $dataText = __($datas->name, 'wpshop'); |
|
| 186 | + elseif (isset($datas->code)) |
|
| 187 | + $dataText = __($datas->code, 'wpshop'); |
|
| 188 | 188 | |
| 189 | - $output .= '<option value="' . $datas->id . '" ' . $selected . ' >' . $dataText. '</option>'; |
|
| 189 | + $output .= '<option value="' . $datas->id . '" ' . $selected . ' >' . $dataText . '</option>'; |
|
| 190 | 190 | } |
| 191 | - elseif(!is_array($comboxOptionToHide) || !in_array($datas, $comboxOptionToHide)){ |
|
| 191 | + elseif (!is_array($comboxOptionToHide) || !in_array($datas, $comboxOptionToHide)) { |
|
| 192 | 192 | $valueToPut = $datas; |
| 193 | 193 | $selected = ($value == $datas) ? ' selected="selected" ' : ''; |
| 194 | - if($optionValue == 'index'){ |
|
| 194 | + if ($optionValue == 'index') { |
|
| 195 | 195 | $valueToPut = $index; |
| 196 | 196 | $selected = ($value == $index) ? ' selected="selected" ' : ''; |
| 197 | 197 | } |
| 198 | - $output .= '<option value="' . $valueToPut . '" ' . $selected . ' >' . __($datas ,'wpshop') . '</option>'; |
|
| 198 | + $output .= '<option value="' . $valueToPut . '" ' . $selected . ' >' . __($datas, 'wpshop') . '</option>'; |
|
| 199 | 199 | } |
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | 202 | else |
| 203 | - $output .= '<option value="" >'.__('Nothing found here...', 'wpshop').'</option>'; |
|
| 203 | + $output .= '<option value="" >' . __('Nothing found here...', 'wpshop') . '</option>'; |
|
| 204 | 204 | |
| 205 | 205 | $output .= '</select>'; |
| 206 | 206 | |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | $values = array(); |
| 223 | 223 | |
| 224 | 224 | if (!empty($value) && (is_array($value))) { |
| 225 | - foreach($value as $v) { |
|
| 225 | + foreach ($value as $v) { |
|
| 226 | 226 | $values[] = $v->value; |
| 227 | 227 | } |
| 228 | 228 | } |
@@ -234,8 +234,8 @@ discard block |
||
| 234 | 234 | if (is_array($content) && (count($content) > 0)) { |
| 235 | 235 | $output = '<select id="' . $id . '" name="' . $name . '[]" ' . $option . ' multiple size="4" data-placeholder="' . __('Select values from list', 'wpshop') . '" >'; |
| 236 | 236 | |
| 237 | - foreach($content as $index => $datas) { |
|
| 238 | - if ( !empty($datas) && !empty($index) ) { |
|
| 237 | + foreach ($content as $index => $datas) { |
|
| 238 | + if (!empty($datas) && !empty($index)) { |
|
| 239 | 239 | $selected = in_array($index, $values) ? ' selected="selected" ' : ''; |
| 240 | 240 | |
| 241 | 241 | $output .= '<option value="' . $index . '" ' . $selected . ' >' . $datas . '</option>'; |
@@ -260,41 +260,41 @@ discard block |
||
| 260 | 260 | * |
| 261 | 261 | * @return mixed $output The output code to add to the form |
| 262 | 262 | */ |
| 263 | - public static function form_input_check($name, $id, $content, $value = '', $type = 'checkbox', $option = '', $optionValue = '', $input_label=''){ |
|
| 263 | + public static function form_input_check($name, $id, $content, $value = '', $type = 'checkbox', $option = '', $optionValue = '', $input_label = '') { |
|
| 264 | 264 | $output = ''; |
| 265 | 265 | $allowedType = array('checkbox', 'radio'); |
| 266 | 266 | $container_start = (isset($input_label['container']) && $input_label['container'] ? '<div class="wpshop_input_' . $type . ' wpshop_input_' . $type . '_' . $id . '" >' : ''); |
| 267 | 267 | $container_end = (isset($input_label['container']) && $input_label['container'] ? '</div>' : ''); |
| 268 | 268 | |
| 269 | - if(in_array($type, $allowedType)){ |
|
| 270 | - if(is_array($content) && (count($content) > 0)){ |
|
| 271 | - foreach($content as $index => $datas){ |
|
| 272 | - if(is_object($datas)){ |
|
| 269 | + if (in_array($type, $allowedType)) { |
|
| 270 | + if (is_array($content) && (count($content) > 0)) { |
|
| 271 | + foreach ($content as $index => $datas) { |
|
| 272 | + if (is_object($datas)) { |
|
| 273 | 273 | $id = $name . '_' . sanitize_title($datas->nom); |
| 274 | 274 | $checked = ($value == $datas->id) ? ' checked="checked" ' : ''; |
| 275 | 275 | } |
| 276 | - else{ |
|
| 276 | + else { |
|
| 277 | 277 | |
| 278 | 278 | $valueToPut = $datas; |
| 279 | - $checked = ( ($value == $datas) || (is_array($value) && in_array($valueToPut, $value))) ? ' checked="checked" ' : ''; |
|
| 280 | - if($optionValue == 'index'){ |
|
| 279 | + $checked = (($value == $datas) || (is_array($value) && in_array($valueToPut, $value))) ? ' checked="checked" ' : ''; |
|
| 280 | + if ($optionValue == 'index') { |
|
| 281 | 281 | $valueToPut = $index; |
| 282 | - $checked = ( ($value == $index) || (is_array($value) && in_array($valueToPut, $value))) ? ' checked="checked" ' : ''; |
|
| 282 | + $checked = (($value == $index) || (is_array($value) && in_array($valueToPut, $value))) ? ' checked="checked" ' : ''; |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | $id = $id . '_' . sanitize_title($datas); |
| 286 | 286 | // $checked = ( ($value == $datas) || (is_array($value) && in_array($valueToPut, $value))) ? ' checked="checked" ' : ''; |
| 287 | - $output .= $container_start . '<input type="' . $type . '" name="' . $name . '" id="' . $id . '" value="' . $valueToPut . '" ' . $checked . ' ' . $option . ' />'.(!empty($input_label['original'])?'<label for="' . $id . '">'.__($datas,'wpshop').'</label> ':'') . $container_end ; |
|
| 287 | + $output .= $container_start . '<input type="' . $type . '" name="' . $name . '" id="' . $id . '" value="' . $valueToPut . '" ' . $checked . ' ' . $option . ' />' . (!empty($input_label['original']) ? '<label for="' . $id . '">' . __($datas, 'wpshop') . '</label> ' : '') . $container_end; |
|
| 288 | 288 | } |
| 289 | 289 | } |
| 290 | 290 | } |
| 291 | - else{ |
|
| 291 | + else { |
|
| 292 | 292 | $checked = (($value != '') && ($value == $content)) ? ' checked="checked" ' : ''; |
| 293 | - $output .= $container_start . '<input type="' . $type . '" name="' . $name . '" id="' . $id . '" value="' . $content . '" ' . $checked . ' ' . $option . ' />' . $container_start ; |
|
| 293 | + $output .= $container_start . '<input type="' . $type . '" name="' . $name . '" id="' . $id . '" value="' . $content . '" ' . $checked . ' ' . $option . ' />' . $container_start; |
|
| 294 | 294 | } |
| 295 | - $output.=(is_array($input_label) && !empty($input_label['custom']) ? '<label for="' . $id . '">'.$input_label['custom'].'</label> ':''); |
|
| 295 | + $output .= (is_array($input_label) && !empty($input_label['custom']) ? '<label for="' . $id . '">' . $input_label['custom'] . '</label> ' : ''); |
|
| 296 | 296 | |
| 297 | - if ( isset($input_label['container']) && $input_label['container'] ) $output .= '<div class="wpshop_cls" ></div>'; |
|
| 297 | + if (isset($input_label['container']) && $input_label['container']) $output .= '<div class="wpshop_cls" ></div>'; |
|
| 298 | 298 | return $output; |
| 299 | 299 | } |
| 300 | 300 | else |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | |
| 3 | 5 | /* Check if file is include. No direct access possible with file url */ |
| 4 | 6 | if ( !defined( 'WPSHOP_VERSION' ) ) { |
@@ -52,8 +54,7 @@ discard block |
||
| 52 | 54 | <label ' . $label . ' >' . __($input_name, 'wpshop') . '</label> : |
| 53 | 55 | ' . $the_input . ' |
| 54 | 56 | </div>'; |
| 55 | - } |
|
| 56 | - else |
|
| 57 | + } else |
|
| 57 | 58 | { |
| 58 | 59 | $the_form_content_hidden .= ' |
| 59 | 60 | ' . $the_input; |
@@ -77,46 +78,55 @@ discard block |
||
| 77 | 78 | public static function check_input_type($input_def, $input_domain = '') { |
| 78 | 79 | |
| 79 | 80 | $input_option = ''; |
| 80 | - if(!empty($input_def['option']) && $input_def['option']) |
|
| 81 | - $input_option = $input_def['option']; |
|
| 81 | + if(!empty($input_def['option']) && $input_def['option']) { |
|
| 82 | + $input_option = $input_def['option']; |
|
| 83 | + } |
|
| 82 | 84 | |
| 83 | 85 | $valueToPut = ''; |
| 84 | - if(!empty($input_def['valueToPut']) && $input_def['valueToPut']) |
|
| 85 | - $valueToPut = $input_def['valueToPut']; |
|
| 86 | + if(!empty($input_def['valueToPut']) && $input_def['valueToPut']) { |
|
| 87 | + $valueToPut = $input_def['valueToPut']; |
|
| 88 | + } |
|
| 86 | 89 | |
| 87 | 90 | $input_id = $input_def['name']; |
| 88 | - if(!empty($input_def['id'])) |
|
| 89 | - $input_id = $input_def['id']; |
|
| 91 | + if(!empty($input_def['id'])) { |
|
| 92 | + $input_id = $input_def['id']; |
|
| 93 | + } |
|
| 90 | 94 | |
| 91 | 95 | $input_name = $input_def['name']; |
| 92 | - if($input_domain != '') |
|
| 93 | - $input_name = $input_domain . '[' . $input_def['name'] . ']'; |
|
| 96 | + if($input_domain != '') { |
|
| 97 | + $input_name = $input_domain . '[' . $input_def['name'] . ']'; |
|
| 98 | + } |
|
| 94 | 99 | /** Format data for saving without special chars */ |
| 95 | - if(!empty($input_def['value']) && !is_array($input_def['value']) && preg_match("/^-?(?:\d+|\d*\.\d+)$/", $input_def['value'])) |
|
| 96 | - $input_value = str_replace('.',',',$input_def['value']/* /1 */); // format francais avec virgule |
|
| 97 | - else $input_value = (!empty($input_def['value']) ? $input_def['value'] : ''); |
|
| 100 | + if(!empty($input_def['value']) && !is_array($input_def['value']) && preg_match("/^-?(?:\d+|\d*\.\d+)$/", $input_def['value'])) { |
|
| 101 | + $input_value = str_replace('.',',',$input_def['value']/* /1 */); |
|
| 102 | + } |
|
| 103 | + // format francais avec virgule |
|
| 104 | + else { |
|
| 105 | + $input_value = (!empty($input_def['value']) ? $input_def['value'] : ''); |
|
| 106 | + } |
|
| 98 | 107 | |
| 99 | 108 | $input_type = $input_def['type']; |
| 100 | 109 | $the_input = ''; |
| 101 | 110 | |
| 102 | - if( ( $input_type == 'text' ) || ( $input_type == 'email' ) || ( $input_type == 'tel' ) ) |
|
| 103 | - $the_input .= self::form_input( $input_name, $input_id, $input_value, 'text', $input_option, (!empty($input_def['options_label']) ? $input_def['options_label'] : '') ); |
|
| 104 | - elseif($input_type == 'password') |
|
| 105 | - $the_input .= self::form_input($input_name, $input_id, $input_value, 'password', $input_option); |
|
| 106 | - elseif($input_type == 'textarea') |
|
| 107 | - $the_input .= self::form_input_textarea($input_name, $input_id, $input_value, $input_option); |
|
| 108 | - elseif($input_type == 'hidden') |
|
| 109 | - $the_input .= self::form_input($input_name, $input_id, $input_value, 'hidden', $input_option); |
|
| 110 | - elseif($input_type == 'select') |
|
| 111 | - $the_input .= self::form_input_select($input_name, $input_id, ( !empty($input_def['possible_value']) ? $input_def['possible_value'] : array() ), $input_value, $input_option, $valueToPut); |
|
| 112 | - elseif($input_type == 'multiple-select') |
|
| 113 | - $the_input .= self::form_input_multiple_select($input_name, $input_id, ( !empty($input_def['possible_value']) ? $input_def['possible_value'] : array() ), $input_value, $input_option, $valueToPut); |
|
| 114 | - elseif(($input_type == 'radio') || ($input_type == 'checkbox')) |
|
| 115 | - $the_input .= self::form_input_check($input_name, $input_id, ( !empty($input_def['possible_value']) ? $input_def['possible_value'] : array() ), $input_value, $input_type, $input_option, $valueToPut, (!empty($input_def['options_label']) ? $input_def['options_label'] : '')); |
|
| 116 | - elseif($input_type == 'file') |
|
| 117 | - $the_input .= self::form_input($input_name, $input_id, $input_value, 'file', $input_option); |
|
| 118 | - elseif($input_type == 'gallery') |
|
| 119 | - $the_input .= self::form_input($input_name, $input_id, $input_value, 'text', 'readonly = "readonly"') . 'Gallery field to check'; |
|
| 111 | + if( ( $input_type == 'text' ) || ( $input_type == 'email' ) || ( $input_type == 'tel' ) ) { |
|
| 112 | + $the_input .= self::form_input( $input_name, $input_id, $input_value, 'text', $input_option, (!empty($input_def['options_label']) ? $input_def['options_label'] : '') ); |
|
| 113 | + } elseif($input_type == 'password') { |
|
| 114 | + $the_input .= self::form_input($input_name, $input_id, $input_value, 'password', $input_option); |
|
| 115 | + } elseif($input_type == 'textarea') { |
|
| 116 | + $the_input .= self::form_input_textarea($input_name, $input_id, $input_value, $input_option); |
|
| 117 | + } elseif($input_type == 'hidden') { |
|
| 118 | + $the_input .= self::form_input($input_name, $input_id, $input_value, 'hidden', $input_option); |
|
| 119 | + } elseif($input_type == 'select') { |
|
| 120 | + $the_input .= self::form_input_select($input_name, $input_id, ( !empty($input_def['possible_value']) ? $input_def['possible_value'] : array() ), $input_value, $input_option, $valueToPut); |
|
| 121 | + } elseif($input_type == 'multiple-select') { |
|
| 122 | + $the_input .= self::form_input_multiple_select($input_name, $input_id, ( !empty($input_def['possible_value']) ? $input_def['possible_value'] : array() ), $input_value, $input_option, $valueToPut); |
|
| 123 | + } elseif(($input_type == 'radio') || ($input_type == 'checkbox')) { |
|
| 124 | + $the_input .= self::form_input_check($input_name, $input_id, ( !empty($input_def['possible_value']) ? $input_def['possible_value'] : array() ), $input_value, $input_type, $input_option, $valueToPut, (!empty($input_def['options_label']) ? $input_def['options_label'] : '')); |
|
| 125 | + } elseif($input_type == 'file') { |
|
| 126 | + $the_input .= self::form_input($input_name, $input_id, $input_value, 'file', $input_option); |
|
| 127 | + } elseif($input_type == 'gallery') { |
|
| 128 | + $the_input .= self::form_input($input_name, $input_id, $input_value, 'text', 'readonly = "readonly"') . 'Gallery field to check'; |
|
| 129 | + } |
|
| 120 | 130 | |
| 121 | 131 | return $the_input; |
| 122 | 132 | } |
@@ -136,8 +146,7 @@ discard block |
||
| 136 | 146 | if(in_array($type, $allowedType)) |
| 137 | 147 | { |
| 138 | 148 | $output = '<input type="' . $type . '" name="' . $name . '" id="' . $id . '" value="' . $value . '" ' . $option . ' />' ; |
| 139 | - } |
|
| 140 | - else |
|
| 149 | + } else |
|
| 141 | 150 | { |
| 142 | 151 | return sprintf(__('Input type not allowed here in %s at line %s', 'wpshop'), __FILE__, __LINE__); |
| 143 | 152 | } |
@@ -181,14 +190,14 @@ discard block |
||
| 181 | 190 | $selected = ($value == $datas->id) ? ' selected="selected" ' : ''; |
| 182 | 191 | |
| 183 | 192 | $dataText = __('Nothing to output' ,'wpshop'); |
| 184 | - if(isset($datas->name)) |
|
| 185 | - $dataText = __($datas->name ,'wpshop'); |
|
| 186 | - elseif(isset($datas->code)) |
|
| 187 | - $dataText = __($datas->code ,'wpshop'); |
|
| 193 | + if(isset($datas->name)) { |
|
| 194 | + $dataText = __($datas->name ,'wpshop'); |
|
| 195 | + } elseif(isset($datas->code)) { |
|
| 196 | + $dataText = __($datas->code ,'wpshop'); |
|
| 197 | + } |
|
| 188 | 198 | |
| 189 | 199 | $output .= '<option value="' . $datas->id . '" ' . $selected . ' >' . $dataText. '</option>'; |
| 190 | - } |
|
| 191 | - elseif(!is_array($comboxOptionToHide) || !in_array($datas, $comboxOptionToHide)){ |
|
| 200 | + } elseif(!is_array($comboxOptionToHide) || !in_array($datas, $comboxOptionToHide)){ |
|
| 192 | 201 | $valueToPut = $datas; |
| 193 | 202 | $selected = ($value == $datas) ? ' selected="selected" ' : ''; |
| 194 | 203 | if($optionValue == 'index'){ |
@@ -198,9 +207,9 @@ discard block |
||
| 198 | 207 | $output .= '<option value="' . $valueToPut . '" ' . $selected . ' >' . __($datas ,'wpshop') . '</option>'; |
| 199 | 208 | } |
| 200 | 209 | } |
| 210 | + } else { |
|
| 211 | + $output .= '<option value="" >'.__('Nothing found here...', 'wpshop').'</option>'; |
|
| 201 | 212 | } |
| 202 | - else |
|
| 203 | - $output .= '<option value="" >'.__('Nothing found here...', 'wpshop').'</option>'; |
|
| 204 | 213 | |
| 205 | 214 | $output .= '</select>'; |
| 206 | 215 | |
@@ -225,8 +234,7 @@ discard block |
||
| 225 | 234 | foreach($value as $v) { |
| 226 | 235 | $values[] = $v->value; |
| 227 | 236 | } |
| 228 | - } |
|
| 229 | - else { |
|
| 237 | + } else { |
|
| 230 | 238 | $values = (array)$value; |
| 231 | 239 | } |
| 232 | 240 | |
@@ -272,8 +280,7 @@ discard block |
||
| 272 | 280 | if(is_object($datas)){ |
| 273 | 281 | $id = $name . '_' . sanitize_title($datas->nom); |
| 274 | 282 | $checked = ($value == $datas->id) ? ' checked="checked" ' : ''; |
| 275 | - } |
|
| 276 | - else{ |
|
| 283 | + } else{ |
|
| 277 | 284 | |
| 278 | 285 | $valueToPut = $datas; |
| 279 | 286 | $checked = ( ($value == $datas) || (is_array($value) && in_array($valueToPut, $value))) ? ' checked="checked" ' : ''; |
@@ -287,18 +294,19 @@ discard block |
||
| 287 | 294 | $output .= $container_start . '<input type="' . $type . '" name="' . $name . '" id="' . $id . '" value="' . $valueToPut . '" ' . $checked . ' ' . $option . ' />'.(!empty($input_label['original'])?'<label for="' . $id . '">'.__($datas,'wpshop').'</label> ':'') . $container_end ; |
| 288 | 295 | } |
| 289 | 296 | } |
| 290 | - } |
|
| 291 | - else{ |
|
| 297 | + } else{ |
|
| 292 | 298 | $checked = (($value != '') && ($value == $content)) ? ' checked="checked" ' : ''; |
| 293 | 299 | $output .= $container_start . '<input type="' . $type . '" name="' . $name . '" id="' . $id . '" value="' . $content . '" ' . $checked . ' ' . $option . ' />' . $container_start ; |
| 294 | 300 | } |
| 295 | 301 | $output.=(is_array($input_label) && !empty($input_label['custom']) ? '<label for="' . $id . '">'.$input_label['custom'].'</label> ':''); |
| 296 | 302 | |
| 297 | - if ( isset($input_label['container']) && $input_label['container'] ) $output .= '<div class="wpshop_cls" ></div>'; |
|
| 303 | + if ( isset($input_label['container']) && $input_label['container'] ) { |
|
| 304 | + $output .= '<div class="wpshop_cls" ></div>'; |
|
| 305 | + } |
|
| 298 | 306 | return $output; |
| 307 | + } else { |
|
| 308 | + return sprintf(__('Input type not allowed here in %s at line %s', 'wpshop'), __FILE__, __LINE__); |
|
| 299 | 309 | } |
| 300 | - else |
|
| 301 | - return sprintf(__('Input type not allowed here in %s at line %s', 'wpshop'), __FILE__, __LINE__); |
|
| 302 | 310 | } |
| 303 | 311 | |
| 304 | 312 | } |
| 305 | 313 | \ No newline at end of file |
@@ -98,7 +98,6 @@ |
||
| 98 | 98 | /** |
| 99 | 99 | * Get the sub categories of a given category |
| 100 | 100 | * |
| 101 | - * @param integer $parent_category The main category we want to have the sub categories for |
|
| 102 | 101 | */ |
| 103 | 102 | function category_tree_selector_output($category_id = 0, $wpshop_widget_categories, $instance){ |
| 104 | 103 | $category_tree_output = ''; |
@@ -33,10 +33,10 @@ discard block |
||
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | - * Define the content for the widget |
|
| 37 | - * |
|
| 38 | - * @param mixed $instance The current widget instance |
|
| 39 | - */ |
|
| 36 | + * Define the content for the widget |
|
| 37 | + * |
|
| 38 | + * @param mixed $instance The current widget instance |
|
| 39 | + */ |
|
| 40 | 40 | function form($instance){ |
| 41 | 41 | $instance = wp_parse_args((array) $instance, array( |
| 42 | 42 | 'title' => '', |
@@ -72,11 +72,11 @@ discard block |
||
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
| 75 | - * Widget Output |
|
| 76 | - * |
|
| 77 | - * @param array $args |
|
| 78 | - * @param array $instance Widget values. |
|
| 79 | - */ |
|
| 75 | + * Widget Output |
|
| 76 | + * |
|
| 77 | + * @param array $args |
|
| 78 | + * @param array $instance Widget values. |
|
| 79 | + */ |
|
| 80 | 80 | function widget($args, $instance){ |
| 81 | 81 | $widget_content = ''; |
| 82 | 82 | |
@@ -96,10 +96,10 @@ discard block |
||
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
| 99 | - * Get the sub categories of a given category |
|
| 100 | - * |
|
| 101 | - * @param integer $parent_category The main category we want to have the sub categories for |
|
| 102 | - */ |
|
| 99 | + * Get the sub categories of a given category |
|
| 100 | + * |
|
| 101 | + * @param integer $parent_category The main category we want to have the sub categories for |
|
| 102 | + */ |
|
| 103 | 103 | function category_tree_selector_output($category_id = 0, $wpshop_widget_categories, $instance){ |
| 104 | 104 | $category_tree_output = ''; |
| 105 | 105 | |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | /** |
| 3 | 3 | * WpShop categories menu widget management |
| 4 | 4 | * |
@@ -22,14 +22,14 @@ discard block |
||
| 22 | 22 | * Widget Constructor |
| 23 | 23 | */ |
| 24 | 24 | public function __construct() { |
| 25 | - add_action('widgets_init', create_function('', 'return register_widget("WP_Widget_Wpshop_Product_categories");' ) ); |
|
| 25 | + add_action('widgets_init', create_function('', 'return register_widget("WP_Widget_Wpshop_Product_categories");')); |
|
| 26 | 26 | |
| 27 | 27 | $params = array( |
| 28 | 28 | 'classname' => 'widget_wpshop_pdt_categories', |
| 29 | 29 | 'description' => __('Wpshop product categories widget', 'wpshop') |
| 30 | 30 | ); |
| 31 | 31 | |
| 32 | - parent::__construct( 'wpshop_pdt_categories', __('• Wpshop Categories', 'wpshop'), $params ); |
|
| 32 | + parent::__construct('wpshop_pdt_categories', __('• Wpshop Categories', 'wpshop'), $params); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -37,36 +37,36 @@ discard block |
||
| 37 | 37 | * |
| 38 | 38 | * @param mixed $instance The current widget instance |
| 39 | 39 | */ |
| 40 | - function form($instance){ |
|
| 41 | - $instance = wp_parse_args((array) $instance, array( |
|
| 40 | + function form($instance) { |
|
| 41 | + $instance = wp_parse_args((array)$instance, array( |
|
| 42 | 42 | 'title' => '', |
| 43 | 43 | 'show_product' => '', |
| 44 | 44 | 'show_all_cat' => '', |
| 45 | 45 | 'wpshop_widget_categories' => '' |
| 46 | 46 | )); |
| 47 | 47 | |
| 48 | - $title = esc_attr($instance['title']); |
|
| 48 | + $title = esc_attr($instance['title']); |
|
| 49 | 49 | $show_all_cat = esc_attr($instance['show_all_cat']); |
| 50 | 50 | $show_product = esc_attr($instance['show_product']); |
| 51 | - if ( !isset( $instance['wpshop_widget_categories'] ) ){ |
|
| 51 | + if (!isset($instance['wpshop_widget_categories'])) { |
|
| 52 | 52 | $categories = get_terms(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES, array('hide_empty' => '0', 'parent' => 0)); |
| 53 | - if(!empty($categories)){ |
|
| 54 | - foreach($categories as $category){ |
|
| 53 | + if (!empty($categories)) { |
|
| 54 | + foreach ($categories as $category) { |
|
| 55 | 55 | $instance['wpshop_widget_categories'][$category->term_id] = 'on'; |
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | - $wpshop_widget_categories = esc_attr($instance['wpshop_widget_categories']); |
|
| 59 | + $wpshop_widget_categories = esc_attr($instance['wpshop_widget_categories']); |
|
| 60 | 60 | $checked = (($show_product != '') && ($show_product == 'yes')) ? 'checked="checked"' : ''; |
| 61 | 61 | ?> |
| 62 | 62 | <p> |
| 63 | - <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title', 'wpshop' ); ?></label> |
|
| 64 | - <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $title; ?>" /> |
|
| 63 | + <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title', 'wpshop'); ?></label> |
|
| 64 | + <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /> |
|
| 65 | 65 | </p> |
| 66 | 66 | <p> |
| 67 | - <input id="<?php echo $this->get_field_id( 'show_all_cat' ); ?>" class="wpshop-widget-all-cat" name="<?php echo $this->get_field_name( 'show_all_cat' ); ?>" type="hidden" value="yes" /> |
|
| 68 | - <input <?php echo $checked; ?> id="<?php echo $this->get_field_id( 'show_product' ); ?>" name="<?php echo $this->get_field_name( 'show_product' ); ?>" type="checkbox" value="yes" /> |
|
| 69 | - <label for="<?php echo $this->get_field_id( 'show_product' ); ?>" ><?php _e( 'Show product', 'wpshop' ); ?></label> |
|
| 67 | + <input id="<?php echo $this->get_field_id('show_all_cat'); ?>" class="wpshop-widget-all-cat" name="<?php echo $this->get_field_name('show_all_cat'); ?>" type="hidden" value="yes" /> |
|
| 68 | + <input <?php echo $checked; ?> id="<?php echo $this->get_field_id('show_product'); ?>" name="<?php echo $this->get_field_name('show_product'); ?>" type="checkbox" value="yes" /> |
|
| 69 | + <label for="<?php echo $this->get_field_id('show_product'); ?>" ><?php _e('Show product', 'wpshop'); ?></label> |
|
| 70 | 70 | </p> |
| 71 | 71 | <?php |
| 72 | 72 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * @param array $args |
| 78 | 78 | * @param array $instance Widget values. |
| 79 | 79 | */ |
| 80 | - function widget($args, $instance){ |
|
| 80 | + function widget($args, $instance) { |
|
| 81 | 81 | $widget_content = ''; |
| 82 | 82 | |
| 83 | 83 | /* Get the default args from wordpress */ |
@@ -100,12 +100,12 @@ discard block |
||
| 100 | 100 | * |
| 101 | 101 | * @param integer $parent_category The main category we want to have the sub categories for |
| 102 | 102 | */ |
| 103 | - function category_tree_selector_output($category_id = 0, $wpshop_widget_categories, $instance){ |
|
| 103 | + function category_tree_selector_output($category_id = 0, $wpshop_widget_categories, $instance) { |
|
| 104 | 104 | $category_tree_output = ''; |
| 105 | 105 | |
| 106 | 106 | $categories = get_terms(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES, array('hide_empty' => '0', 'parent' => $category_id)); |
| 107 | - if(count($categories) > 0){ |
|
| 108 | - foreach($categories as $category){ |
|
| 107 | + if (count($categories) > 0) { |
|
| 108 | + foreach ($categories as $category) { |
|
| 109 | 109 | $checked = (is_array($instance['wpshop_widget_categories']) && in_array($category->term_id, $instance['wpshop_widget_categories'])) ? ' checked="checked" ' : ''; |
| 110 | 110 | $category_main_class = ($category_id > 0) ? 'class="wpshop_categories_children"' : ''; |
| 111 | 111 | $category_tree_output .= ' |
@@ -1,4 +1,6 @@ |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | /** |
| 3 | 5 | * WpShop categories menu widget management |
| 4 | 6 | * |
@@ -45,6 +45,7 @@ discard block |
||
| 45 | 45 | /** |
| 46 | 46 | * Get the url listing slug of the current class |
| 47 | 47 | * |
| 48 | + * @param string $message |
|
| 48 | 49 | * @return string The table of the class |
| 49 | 50 | */ |
| 50 | 51 | function setMessage($message){ |
@@ -665,7 +666,7 @@ discard block |
||
| 665 | 666 | /** |
| 666 | 667 | * Display inteface allowing to manage the attribute set and group details |
| 667 | 668 | * |
| 668 | - * @param object $atributeSetId The element's identifier we have to manage the details for |
|
| 669 | + * @param object $attributeSetId The element's identifier we have to manage the details for |
|
| 669 | 670 | * |
| 670 | 671 | * @return string $attributeSetDetailsManagement The html output of management interface |
| 671 | 672 | */ |
@@ -949,7 +950,7 @@ discard block |
||
| 949 | 950 | * @param integer $attributeSetId The attribute set identifier we want to get the details for |
| 950 | 951 | * @param string $attributeSetStatus optionnal The attribute set status. Allows to define if we want all attribute sets or a deleted or valid and so on |
| 951 | 952 | * |
| 952 | - * @return array $attributeSetDetailsGroups The List of attribute and attribute groups for the given attribute set |
|
| 953 | + * @return string $attributeSetDetailsGroups The List of attribute and attribute groups for the given attribute set |
|
| 953 | 954 | */ |
| 954 | 955 | public static function getAttributeSetDetails($attributeSetId, $attributeSetStatus = "'valid', 'moderated'"){ |
| 955 | 956 | global $wpdb, $validAttributeList; |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | |
| 3 | 5 | /* Check if file is include. No direct access possible with file url */ |
| 4 | 6 | if ( !defined( 'WPSHOP_VERSION' ) ) { |
@@ -88,9 +90,9 @@ discard block |
||
| 88 | 90 | if($action == 'edit'){ |
| 89 | 91 | $editedItem = self::getElement($objectInEdition); |
| 90 | 92 | $title = sprintf(__(self::pageEditingTitle, 'wpshop'), __($editedItem->name, 'wpshop'), __($editedItem->entity, 'wpshop')); |
| 93 | + } elseif($action == 'add') { |
|
| 94 | + $title = __(self::pageAddingTitle, 'wpshop'); |
|
| 91 | 95 | } |
| 92 | - elseif($action == 'add') |
|
| 93 | - $title = __(self::pageAddingTitle, 'wpshop'); |
|
| 94 | 96 | } |
| 95 | 97 | return $title; |
| 96 | 98 | } |
@@ -114,8 +116,7 @@ discard block |
||
| 114 | 116 | if(($action != '') && ($action == 'saveok') && ($saveditem > 0)){ |
| 115 | 117 | $editedElement = self::getElement($saveditem); |
| 116 | 118 | $pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully saved', 'wpshop'), '<span class="bold" >' . $editedElement->name . '</span>'); |
| 117 | - } |
|
| 118 | - elseif(($action != '') && ($action == 'deleteok') && ($saveditem > 0)){ |
|
| 119 | + } elseif(($action != '') && ($action == 'deleteok') && ($saveditem > 0)){ |
|
| 119 | 120 | $editedElement = self::getElement($saveditem, "'deleted'"); |
| 120 | 121 | $pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully deleted', 'wpshop'), '<span class="bold" >' . $editedElement->name . '</span>'); |
| 121 | 122 | } |
@@ -141,14 +142,14 @@ discard block |
||
| 141 | 142 | if(current_user_can('wpshop_edit_attribute_set')){ |
| 142 | 143 | $attribute_set_parameter['last_update_date'] = date('Y-m-d H:i:s'); |
| 143 | 144 | if($pageAction == 'delete'){ |
| 144 | - if(current_user_can('wpshop_delete_attribute_set')) |
|
| 145 | - $attribute_set_parameter['status'] = 'deleted'; |
|
| 146 | - else |
|
| 147 | - $actionResult = 'userNotAllowedForActionDelete'; |
|
| 145 | + if(current_user_can('wpshop_delete_attribute_set')) { |
|
| 146 | + $attribute_set_parameter['status'] = 'deleted'; |
|
| 147 | + } else { |
|
| 148 | + $actionResult = 'userNotAllowedForActionDelete'; |
|
| 149 | + } |
|
| 148 | 150 | } |
| 149 | 151 | $actionResult = wpshop_database::update($attribute_set_parameter, $id, self::getDbTable()); |
| 150 | - } |
|
| 151 | - else{ |
|
| 152 | + } else{ |
|
| 152 | 153 | $actionResult = 'userNotAllowedForActionEdit'; |
| 153 | 154 | } |
| 154 | 155 | |
@@ -199,17 +200,15 @@ discard block |
||
| 199 | 200 | |
| 200 | 201 | } |
| 201 | 202 | |
| 202 | - } |
|
| 203 | - elseif(($pageAction != '') && (($pageAction == 'delete'))){ |
|
| 203 | + } elseif(($pageAction != '') && (($pageAction == 'delete'))){ |
|
| 204 | 204 | if(current_user_can('wpshop_delete_attribute_set')){ |
| 205 | 205 | $attribute_set_parameter['last_update_date'] = date('Y-m-d H:i:s'); |
| 206 | 206 | $attribute_set_parameter['status'] = 'deleted'; |
| 207 | 207 | $actionResult = wpshop_database::update($attribute_set_parameter, $id, self::getDbTable()); |
| 208 | + } else { |
|
| 209 | + $actionResult = 'userNotAllowedForActionDelete'; |
|
| 208 | 210 | } |
| 209 | - else |
|
| 210 | - $actionResult = 'userNotAllowedForActionDelete'; |
|
| 211 | - } |
|
| 212 | - elseif(($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))){ |
|
| 211 | + } elseif(($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))){ |
|
| 213 | 212 | if(current_user_can('wpshop_add_attribute_set')){ |
| 214 | 213 | $attribute_set_parameter['creation_date'] = date('Y-m-d H:i:s'); |
| 215 | 214 | $actionResult = wpshop_database::save($attribute_set_parameter, self::getDbTable()); |
@@ -244,9 +243,9 @@ discard block |
||
| 244 | 243 | } |
| 245 | 244 | } |
| 246 | 245 | } |
| 246 | + } else { |
|
| 247 | + $actionResult = 'userNotAllowedForActionAdd'; |
|
| 247 | 248 | } |
| 248 | - else |
|
| 249 | - $actionResult = 'userNotAllowedForActionAdd'; |
|
| 250 | 249 | } |
| 251 | 250 | |
| 252 | 251 | /* When an action is launched and there is a result message */ |
@@ -255,11 +254,12 @@ discard block |
||
| 255 | 254 | /****************************************************************************/ |
| 256 | 255 | if($actionResult != ''){ |
| 257 | 256 | $elementIdentifierForMessage = __('the attribute group', 'wpshop'); |
| 258 | - if(!empty($attribute_set_parameter['name']))$elementIdentifierForMessage = '<span class="bold" >' . $attribute_set_parameter['name'] . '</span>'; |
|
| 257 | + if(!empty($attribute_set_parameter['name'])) { |
|
| 258 | + $elementIdentifierForMessage = '<span class="bold" >' . $attribute_set_parameter['name'] . '</span>'; |
|
| 259 | + } |
|
| 259 | 260 | if($actionResult == 'error'){/* CHANGE HERE FOR SPECIFIC CASE */ |
| 260 | 261 | $pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . sprintf(__('An error occured while saving %s', 'wpshop'), $elementIdentifierForMessage); |
| 261 | - } |
|
| 262 | - elseif(($actionResult == 'done') || ($actionResult == 'nothingToUpdate')){ |
|
| 262 | + } elseif(($actionResult == 'done') || ($actionResult == 'nothingToUpdate')){ |
|
| 263 | 263 | /*****************************************************************************************************************/ |
| 264 | 264 | /************************* CHANGE FOR SPECIFIC ACTION FOR CURRENT ELEMENT ******************/ |
| 265 | 265 | /*****************************************************************************************************************/ |
@@ -284,13 +284,11 @@ discard block |
||
| 284 | 284 | $validElement = $wpdb->get_var($query); |
| 285 | 285 | if(!empty($validElement)){ |
| 286 | 286 | $query = $wpdb->prepare("UPDATE " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " SET position = %d, attribute_group_id = %d, last_update_date = NOW() WHERE attribute_id = %d AND status = %s AND attribute_set_id = %d", $i, $groupId, $element, 'valid', $id); |
| 287 | - } |
|
| 288 | - else{ |
|
| 287 | + } else{ |
|
| 289 | 288 | $query = $wpdb->prepare("INSERT INTO " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " (id, status, creation_date, entity_type_id, attribute_set_id, attribute_group_id, attribute_id, position) VALUES ('', 'valid', NOW(), %d, %d, %d, %d, %d)", $attribute_set_parameter['entity_id'], $id, $groupId, $element, $i); |
| 290 | 289 | } |
| 291 | 290 | $wpdb->query($query); |
| 292 | - } |
|
| 293 | - else{ |
|
| 291 | + } else{ |
|
| 294 | 292 | $wpdb->update(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'deleted', 'last_update_date' => current_time('mysql', 0), 'position' => 0), array('attribute_id' => $element, 'status' => 'valid', 'attribute_set_id' => $id)); |
| 295 | 293 | } |
| 296 | 294 | $i++; |
@@ -344,13 +342,14 @@ discard block |
||
| 344 | 342 | $pageMessage .= '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully saved', 'wpshop'), $elementIdentifierForMessage); |
| 345 | 343 | /* if(($pageAction == 'edit') || ($pageAction == 'save')) |
| 346 | 344 | wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=saveok&saveditem=" . $id)); |
| 347 | - else */if($pageAction == 'add') |
|
| 348 | - wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page='.self::getListingSlug()."&action=edit&id=".$id)); |
|
| 349 | - elseif($pageAction == 'delete') |
|
| 350 | - wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page='.self::getListingSlug()."&action=deleteok&saveditem=" . $id)); |
|
| 345 | + else */if($pageAction == 'add') { |
|
| 346 | + wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page='.self::getListingSlug()."&action=edit&id=".$id)); |
|
| 347 | + } elseif($pageAction == 'delete') { |
|
| 348 | + wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page='.self::getListingSlug()."&action=deleteok&saveditem=" . $id)); |
|
| 349 | + } |
|
| 350 | + } elseif(($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete')) { |
|
| 351 | + $pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . __('You are not allowed to do this action', 'wpshop'); |
|
| 351 | 352 | } |
| 352 | - elseif(($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete')) |
|
| 353 | - $pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . __('You are not allowed to do this action', 'wpshop'); |
|
| 354 | 353 | } |
| 355 | 354 | |
| 356 | 355 | self::setMessage($pageMessage); |
@@ -391,7 +390,9 @@ discard block |
||
| 391 | 390 | } |
| 392 | 391 | } |
| 393 | 392 | if(!empty($attribute_set_list[$i]['content'])){ |
| 394 | - if($has_att)$attribute_set_list[$i]['content'] = substr($attribute_set_list[$i]['content'],0,-2); |
|
| 393 | + if($has_att) { |
|
| 394 | + $attribute_set_list[$i]['content'] = substr($attribute_set_list[$i]['content'],0,-2); |
|
| 395 | + } |
|
| 395 | 396 | $attribute_set_list[$i]['content'] .= '</div>'; |
| 396 | 397 | } |
| 397 | 398 | } |
@@ -433,8 +434,9 @@ discard block |
||
| 433 | 434 | $bloc_list=array(); |
| 434 | 435 | |
| 435 | 436 | $editedItem = ''; |
| 436 | - if($itemToEdit != '') |
|
| 437 | - $editedItem = self::getElement($itemToEdit); |
|
| 437 | + if($itemToEdit != '') { |
|
| 438 | + $editedItem = self::getElement($itemToEdit); |
|
| 439 | + } |
|
| 438 | 440 | |
| 439 | 441 | foreach($dbFieldList as $input_key => $input_def){ |
| 440 | 442 | $input_name = $input_def['name']; |
@@ -446,14 +448,16 @@ discard block |
||
| 446 | 448 | |
| 447 | 449 | /* Get value by checking current object type */ |
| 448 | 450 | $currentFieldValue = $input_value; |
| 449 | - if(is_object($editedItem)) |
|
| 450 | - $currentFieldValue = $editedItem->$input_name; |
|
| 451 | - elseif(($attributeAction != '') && ($attributeFormValue != '')) |
|
| 452 | - $currentFieldValue = $attributeFormValue; |
|
| 451 | + if(is_object($editedItem)) { |
|
| 452 | + $currentFieldValue = $editedItem->$input_name; |
|
| 453 | + } elseif(($attributeAction != '') && ($attributeFormValue != '')) { |
|
| 454 | + $currentFieldValue = $attributeFormValue; |
|
| 455 | + } |
|
| 453 | 456 | |
| 454 | 457 | /* Check if the field must be hidden */ |
| 455 | - if(in_array($input_name, $attribute_hidden_field)) |
|
| 456 | - $input_def['type'] = 'hidden'; |
|
| 458 | + if(in_array($input_name, $attribute_hidden_field)) { |
|
| 459 | + $input_def['type'] = 'hidden'; |
|
| 460 | + } |
|
| 457 | 461 | if ($input_name == 'entity_id') { |
| 458 | 462 | $input_def['type'] = 'select'; |
| 459 | 463 | $input_def['possible_value'] = wpshop_entities::get_entities_list(); |
@@ -475,8 +479,7 @@ discard block |
||
| 475 | 479 | } |
| 476 | 480 | |
| 477 | 481 | $the_input = wpshop_form::check_input_type($input_def, self::getDbTable()); |
| 478 | - } |
|
| 479 | - else { |
|
| 482 | + } else { |
|
| 480 | 483 | if(in_array($input_name, array('status', 'default_set'))){ |
| 481 | 484 | $input_def['type'] = 'checkbox'; |
| 482 | 485 | switch($input_name){ |
@@ -503,8 +506,7 @@ discard block |
||
| 503 | 506 | <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_'.$input_name.'" ><label for="'.$input_def_id.'" >' . __($input_name, 'wpshop') . '</label></td> |
| 504 | 507 | <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_input wpshop_' . self::currentPageCode . '_edition_table_field_input_'.$input_name.'" >' . $the_input . '</td> |
| 505 | 508 | </tr>'; |
| 506 | - } |
|
| 507 | - else{ |
|
| 509 | + } else{ |
|
| 508 | 510 | $the_form_content_hidden .= ' |
| 509 | 511 | ' . $the_input; |
| 510 | 512 | } |
@@ -538,13 +540,15 @@ discard block |
||
| 538 | 540 | ' . wpshop_form::form_input(self::getDbTable() . '_form_has_modification', self::getDbTable() . '_form_has_modification', 'no' , 'hidden') . $the_form_content_hidden . wpshop_display::custom_page_output_builder($bloc_list, WPSHOP_ATTRIBUTE_SET_EDITION_PAGE_LAYOUT) . ' |
| 539 | 541 | <div class="wpshop_edition_button wpshop_edition_button_'.self::currentPageCode.'" >'; |
| 540 | 542 | |
| 541 | - if(($action == 'add') && (current_user_can('wpshop_add_attribute_set'))) |
|
| 542 | - $the_form .= '<input type="submit" class="button-primary" id="add" name="add" value="' . __('Add', 'wpshop') . '" />'; |
|
| 543 | - elseif(current_user_can('wpshop_edit_attribute_set')) |
|
| 544 | - $the_form .= '<input type="submit" class="button-primary" id="save" name="save" value="' . __('Save', 'wpshop') . '" />'; |
|
| 543 | + if(($action == 'add') && (current_user_can('wpshop_add_attribute_set'))) { |
|
| 544 | + $the_form .= '<input type="submit" class="button-primary" id="add" name="add" value="' . __('Add', 'wpshop') . '" />'; |
|
| 545 | + } elseif(current_user_can('wpshop_edit_attribute_set')) { |
|
| 546 | + $the_form .= '<input type="submit" class="button-primary" id="save" name="save" value="' . __('Save', 'wpshop') . '" />'; |
|
| 547 | + } |
|
| 545 | 548 | |
| 546 | - if(current_user_can('wpshop_delete_attribute_set') && ($action != 'add')) |
|
| 547 | - $the_form .= '<input type="button" class="button-secondary wpshop_delete_element_button wpshop_delete_element_button_'.self::currentPageCode.'" id="delete" name="delete" value="' . __('Delete', 'wpshop') . '" />'; |
|
| 549 | + if(current_user_can('wpshop_delete_attribute_set') && ($action != 'add')) { |
|
| 550 | + $the_form .= '<input type="button" class="button-secondary wpshop_delete_element_button wpshop_delete_element_button_'.self::currentPageCode.'" id="delete" name="delete" value="' . __('Delete', 'wpshop') . '" />'; |
|
| 551 | + } |
|
| 548 | 552 | |
| 549 | 553 | $the_form .= ' |
| 550 | 554 | </div> |
@@ -650,8 +654,7 @@ discard block |
||
| 650 | 654 | if(($elementId == '') || ($resultList == 'all')) |
| 651 | 655 | { |
| 652 | 656 | $elements = $wpdb->get_results($query); |
| 653 | - } |
|
| 654 | - else |
|
| 657 | + } else |
|
| 655 | 658 | { |
| 656 | 659 | $elements = $wpdb->get_row($query); |
| 657 | 660 | } |
@@ -1149,8 +1152,7 @@ discard block |
||
| 1149 | 1152 | $the_input .= '<option'.$selected.' value="'.$attr_set->id.'_'.$set_details['id'].'">'.__($set_details['name'],'wpshop').'</option>'; |
| 1150 | 1153 | } |
| 1151 | 1154 | $the_input .= '</optgroup>'; |
| 1152 | - } |
|
| 1153 | - else { |
|
| 1155 | + } else { |
|
| 1154 | 1156 | $the_input .= '<option value="'.$attr_set->id.'">'.__($attr_set->name, 'wpshop').'</option>'; |
| 1155 | 1157 | } |
| 1156 | 1158 | } |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | |
| 3 | 3 | /* Check if file is include. No direct access possible with file url */ |
| 4 | -if ( !defined( 'WPSHOP_VERSION' ) ) { |
|
| 5 | - die( __('Access is not allowed by this way', 'wpshop') ); |
|
| 4 | +if (!defined('WPSHOP_VERSION')) { |
|
| 5 | + die(__('Access is not allowed by this way', 'wpshop')); |
|
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | /** |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * @package wpshop |
| 22 | 22 | * @subpackage librairies |
| 23 | 23 | */ |
| 24 | -class wpshop_attributes_set{ |
|
| 24 | +class wpshop_attributes_set { |
|
| 25 | 25 | /* Define the database table used in the current class */ |
| 26 | 26 | const dbTable = WPSHOP_DBT_ATTRIBUTE_SET; |
| 27 | 27 | /* Define the url listing slug used in the current class */ |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * |
| 48 | 48 | * @return string The table of the class |
| 49 | 49 | */ |
| 50 | - function setMessage($message){ |
|
| 50 | + function setMessage($message) { |
|
| 51 | 51 | $this->pageMessage = $message; |
| 52 | 52 | } |
| 53 | 53 | /** |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * |
| 56 | 56 | * @return string The table of the class |
| 57 | 57 | */ |
| 58 | - function getListingSlug(){ |
|
| 58 | + function getListingSlug() { |
|
| 59 | 59 | return self::urlSlugListing; |
| 60 | 60 | } |
| 61 | 61 | /** |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | * |
| 64 | 64 | * @return string The table of the class |
| 65 | 65 | */ |
| 66 | - public static function getEditionSlug(){ |
|
| 66 | + public static function getEditionSlug() { |
|
| 67 | 67 | return self::urlSlugEdition; |
| 68 | 68 | } |
| 69 | 69 | /** |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | * |
| 72 | 72 | * @return string The table of the class |
| 73 | 73 | */ |
| 74 | - public static function getDbTable(){ |
|
| 74 | + public static function getDbTable() { |
|
| 75 | 75 | return self::dbTable; |
| 76 | 76 | } |
| 77 | 77 | /** |
@@ -79,17 +79,17 @@ discard block |
||
| 79 | 79 | * |
| 80 | 80 | * @return string $title The title of the page looking at the environnement |
| 81 | 81 | */ |
| 82 | - function pageTitle(){ |
|
| 82 | + function pageTitle() { |
|
| 83 | 83 | $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : ''; |
| 84 | 84 | $objectInEdition = isset($_REQUEST['id']) ? sanitize_key($_REQUEST['id']) : ''; |
| 85 | 85 | |
| 86 | - $title = __(self::pageTitle, 'wpshop' ); |
|
| 87 | - if($action != ''){ |
|
| 88 | - if($action == 'edit'){ |
|
| 86 | + $title = __(self::pageTitle, 'wpshop'); |
|
| 87 | + if ($action != '') { |
|
| 88 | + if ($action == 'edit') { |
|
| 89 | 89 | $editedItem = self::getElement($objectInEdition); |
| 90 | 90 | $title = sprintf(__(self::pageEditingTitle, 'wpshop'), __($editedItem->name, 'wpshop'), __($editedItem->entity, 'wpshop')); |
| 91 | 91 | } |
| 92 | - elseif($action == 'add') |
|
| 92 | + elseif ($action == 'add') |
|
| 93 | 93 | $title = __(self::pageAddingTitle, 'wpshop'); |
| 94 | 94 | } |
| 95 | 95 | return $title; |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | /** |
| 99 | 99 | * Define the different message and action after an action is send through the element interface |
| 100 | 100 | */ |
| 101 | - function elementAction(){ |
|
| 101 | + function elementAction() { |
|
| 102 | 102 | global $wpdb, $initialEavData; |
| 103 | 103 | $pageMessage = $actionResult = ''; |
| 104 | 104 | |
@@ -107,16 +107,16 @@ discard block |
||
| 107 | 107 | /****************************************************************************/ |
| 108 | 108 | $saveditem = isset($_REQUEST['saveditem']) ? sanitize_text_field($_REQUEST['saveditem']) : ''; |
| 109 | 109 | $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : 'add'; |
| 110 | - $id = !empty( $_REQUEST['id'] ) ? (int)$_REQUEST['id'] : 0; |
|
| 111 | - if(!empty($action) && ($action=='activate') && (!empty($id))){ |
|
| 110 | + $id = !empty($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0; |
|
| 111 | + if (!empty($action) && ($action == 'activate') && (!empty($id))) { |
|
| 112 | 112 | $query = $wpdb->update(self::getDbTable(), array('status'=>'moderated'), array('id'=>sanitize_key($id))); |
| 113 | 113 | wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=edit&id=" . sanitize_key($id))); |
| 114 | 114 | } |
| 115 | - if(($action != '') && ($action == 'saveok') && ($saveditem > 0)){ |
|
| 115 | + if (($action != '') && ($action == 'saveok') && ($saveditem > 0)) { |
|
| 116 | 116 | $editedElement = self::getElement($saveditem); |
| 117 | 117 | $pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully saved', 'wpshop'), '<span class="bold" >' . $editedElement->name . '</span>'); |
| 118 | 118 | } |
| 119 | - elseif(($action != '') && ($action == 'deleteok') && ($saveditem > 0)){ |
|
| 119 | + elseif (($action != '') && ($action == 'deleteok') && ($saveditem > 0)) { |
|
| 120 | 120 | $editedElement = self::getElement($saveditem, "'deleted'"); |
| 121 | 121 | $pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully deleted', 'wpshop'), '<span class="bold" >' . $editedElement->name . '</span>'); |
| 122 | 122 | } |
@@ -124,63 +124,63 @@ discard block |
||
| 124 | 124 | /* Define the database operation type from action launched by the user */ |
| 125 | 125 | /************************* GENERIC ****************************/ |
| 126 | 126 | /*************************************************************************/ |
| 127 | - $attribute_set_parameter = !empty( $_REQUEST[self::getDbTable()] ) ? (array)$_REQUEST[self::getDbTable()] : array(); |
|
| 128 | - $pageAction = isset($_REQUEST[self::getDbTable() . '_action']) ? sanitize_text_field($_REQUEST[self::getDbTable() . '_action']) : ((!empty($_GET['action']) && ($_GET['action']=='delete')) ? sanitize_text_field($_GET['action']) : ''); |
|
| 127 | + $attribute_set_parameter = !empty($_REQUEST[self::getDbTable()]) ? (array)$_REQUEST[self::getDbTable()] : array(); |
|
| 128 | + $pageAction = isset($_REQUEST[self::getDbTable() . '_action']) ? sanitize_text_field($_REQUEST[self::getDbTable() . '_action']) : ((!empty($_GET['action']) && ($_GET['action'] == 'delete')) ? sanitize_text_field($_GET['action']) : ''); |
|
| 129 | 129 | $id = isset($attribute_set_parameter['id']) ? sanitize_key($attribute_set_parameter['id']) : ((!empty($_GET['id'])) ? sanitize_key($_GET['id']) : ''); |
| 130 | 130 | $set_section = !empty($attribute_set_parameter['set_section']) ? sanitize_text_field($attribute_set_parameter['set_section']) : ''; |
| 131 | 131 | unset($attribute_set_parameter['set_section']); |
| 132 | 132 | |
| 133 | 133 | /* Specific case for the attribute groups */ |
| 134 | - if(!isset($attribute_set_parameter['status'])){ |
|
| 134 | + if (!isset($attribute_set_parameter['status'])) { |
|
| 135 | 135 | $attribute_set_parameter['status'] = 'moderated'; |
| 136 | 136 | } |
| 137 | - if(!isset($attribute_set_parameter['default_set'])){ |
|
| 137 | + if (!isset($attribute_set_parameter['default_set'])) { |
|
| 138 | 138 | $attribute_set_parameter['default_set'] = 'no'; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - if(($pageAction != '') && (($pageAction == 'edit') || ($pageAction == 'editandcontinue') || ($pageAction == 'delete'))){ |
|
| 142 | - if(current_user_can('wpshop_edit_attribute_set')){ |
|
| 141 | + if (($pageAction != '') && (($pageAction == 'edit') || ($pageAction == 'editandcontinue') || ($pageAction == 'delete'))) { |
|
| 142 | + if (current_user_can('wpshop_edit_attribute_set')) { |
|
| 143 | 143 | $attribute_set_parameter['last_update_date'] = date('Y-m-d H:i:s'); |
| 144 | - if($pageAction == 'delete'){ |
|
| 145 | - if(current_user_can('wpshop_delete_attribute_set')) |
|
| 144 | + if ($pageAction == 'delete') { |
|
| 145 | + if (current_user_can('wpshop_delete_attribute_set')) |
|
| 146 | 146 | $attribute_set_parameter['status'] = 'deleted'; |
| 147 | 147 | else |
| 148 | 148 | $actionResult = 'userNotAllowedForActionDelete'; |
| 149 | 149 | } |
| 150 | 150 | $actionResult = wpshop_database::update($attribute_set_parameter, $id, self::getDbTable()); |
| 151 | 151 | } |
| 152 | - else{ |
|
| 152 | + else { |
|
| 153 | 153 | $actionResult = 'userNotAllowedForActionEdit'; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | /** Address display managment **/ |
| 157 | - if ( !empty($id) ) { |
|
| 157 | + if (!empty($id)) { |
|
| 158 | 158 | $is_billing = $is_shipping = false; |
| 159 | 159 | /** Get billing option **/ |
| 160 | - $billing_option = get_option( 'wpshop_billing_address' ); |
|
| 161 | - $shipping_option = get_option( 'wpshop_shipping_address_choice' ); |
|
| 160 | + $billing_option = get_option('wpshop_billing_address'); |
|
| 161 | + $shipping_option = get_option('wpshop_shipping_address_choice'); |
|
| 162 | 162 | |
| 163 | - if( !empty($billing_option) && !empty($billing_option['choice']) && $billing_option['choice'] == $id ) { |
|
| 163 | + if (!empty($billing_option) && !empty($billing_option['choice']) && $billing_option['choice'] == $id) { |
|
| 164 | 164 | $is_billing = true; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - if( !empty($shipping_option) && !empty($shipping_option['choice']) && $shipping_option['choice'] == $id ) { |
|
| 167 | + if (!empty($shipping_option) && !empty($shipping_option['choice']) && $shipping_option['choice'] == $id) { |
|
| 168 | 168 | $is_shipping = true; |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - $attribute_group_order = !empty( $_REQUEST['attribute_group_order'] ) ? (array) $_REQUEST['attribute_group_order'] : array(); |
|
| 171 | + $attribute_group_order = !empty($_REQUEST['attribute_group_order']) ? (array)$_REQUEST['attribute_group_order'] : array(); |
|
| 172 | 172 | |
| 173 | 173 | $attribute_display = array(); |
| 174 | - if ( !empty($attribute_group_order)) { |
|
| 174 | + if (!empty($attribute_group_order)) { |
|
| 175 | 175 | |
| 176 | - foreach( $attribute_group_order as $group_id => $group_def ) { |
|
| 176 | + foreach ($attribute_group_order as $group_id => $group_def) { |
|
| 177 | 177 | $end_line_element_id = 0; |
| 178 | - if( $group_id != 'newOrderNotAffectedAttribute' ) { |
|
| 179 | - $attribute_display[ str_replace('newOrder', '', $group_id) ] = explode( ',', $group_def ); |
|
| 178 | + if ($group_id != 'newOrderNotAffectedAttribute') { |
|
| 179 | + $attribute_display[str_replace('newOrder', '', $group_id)] = explode(',', $group_def); |
|
| 180 | 180 | |
| 181 | - foreach( $attribute_display[ str_replace('newOrder', '', $group_id) ] as $att_id => $att ) { |
|
| 182 | - if( $att == 'wps-attribute-end-line' ) { |
|
| 183 | - $attribute_display[ str_replace('newOrder', '', $group_id) ][$att_id] = 'wps-attribute-end-line-'.$end_line_element_id; |
|
| 181 | + foreach ($attribute_display[str_replace('newOrder', '', $group_id)] as $att_id => $att) { |
|
| 182 | + if ($att == 'wps-attribute-end-line') { |
|
| 183 | + $attribute_display[str_replace('newOrder', '', $group_id)][$att_id] = 'wps-attribute-end-line-' . $end_line_element_id; |
|
| 184 | 184 | $end_line_element_id++; |
| 185 | 185 | } |
| 186 | 186 | } |
@@ -190,21 +190,21 @@ discard block |
||
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | |
| 193 | - if ( $is_billing && !$is_shipping ) { |
|
| 193 | + if ($is_billing && !$is_shipping) { |
|
| 194 | 194 | $billing_option['display_model'] = $attribute_display; |
| 195 | - update_option( 'wpshop_billing_address', $billing_option ); |
|
| 195 | + update_option('wpshop_billing_address', $billing_option); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - if ( !$is_billing && $is_shipping ) { |
|
| 198 | + if (!$is_billing && $is_shipping) { |
|
| 199 | 199 | $shipping_option['display_model'] = $attribute_display; |
| 200 | - update_option( 'wpshop_shipping_address_choice', $shipping_option ); |
|
| 200 | + update_option('wpshop_shipping_address_choice', $shipping_option); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | } |
| 206 | - elseif(($pageAction != '') && (($pageAction == 'delete'))){ |
|
| 207 | - if(current_user_can('wpshop_delete_attribute_set')){ |
|
| 206 | + elseif (($pageAction != '') && (($pageAction == 'delete'))) { |
|
| 207 | + if (current_user_can('wpshop_delete_attribute_set')) { |
|
| 208 | 208 | $attribute_set_parameter['last_update_date'] = date('Y-m-d H:i:s'); |
| 209 | 209 | $attribute_set_parameter['status'] = 'deleted'; |
| 210 | 210 | $actionResult = wpshop_database::update($attribute_set_parameter, $id, self::getDbTable()); |
@@ -212,32 +212,32 @@ discard block |
||
| 212 | 212 | else |
| 213 | 213 | $actionResult = 'userNotAllowedForActionDelete'; |
| 214 | 214 | } |
| 215 | - elseif(($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))){ |
|
| 216 | - if(current_user_can('wpshop_add_attribute_set')){ |
|
| 215 | + elseif (($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))) { |
|
| 216 | + if (current_user_can('wpshop_add_attribute_set')) { |
|
| 217 | 217 | $attribute_set_parameter['creation_date'] = date('Y-m-d H:i:s'); |
| 218 | 218 | $actionResult = wpshop_database::save($attribute_set_parameter, self::getDbTable()); |
| 219 | 219 | $id = $wpdb->insert_id; |
| 220 | - if ( empty( $set_section ) ) { |
|
| 221 | - $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_GROUP, array('status' => 'valid', 'attribute_set_id' => $id, 'position' => 1, 'creation_date' => current_time('mysql',0), 'code' => 'general', 'default_group' => 'yes', 'name' => __('Main information', 'wpshop'))); |
|
| 220 | + if (empty($set_section)) { |
|
| 221 | + $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_GROUP, array('status' => 'valid', 'attribute_set_id' => $id, 'position' => 1, 'creation_date' => current_time('mysql', 0), 'code' => 'general', 'default_group' => 'yes', 'name' => __('Main information', 'wpshop'))); |
|
| 222 | 222 | |
| 223 | 223 | $selected_entity_query = $wpdb->prepare("SELECT post_name FROM " . $wpdb->posts . " WHERE ID = %d", $attribute_set_parameter['entity_id']); |
| 224 | 224 | if (WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT == $wpdb->get_var($selected_entity_query)) { |
| 225 | - $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_GROUP, array('status' => 'valid', 'attribute_set_id' => $id, 'position' => 1, 'creation_date' => current_time('mysql',0), 'code' => 'prices', 'default_group' => 'no', 'name' => __('Prices', 'wpshop'))); |
|
| 225 | + $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_GROUP, array('status' => 'valid', 'attribute_set_id' => $id, 'position' => 1, 'creation_date' => current_time('mysql', 0), 'code' => 'prices', 'default_group' => 'no', 'name' => __('Prices', 'wpshop'))); |
|
| 226 | 226 | $price_attribute_set_id = $wpdb->insert_id; |
| 227 | 227 | $price_tab = unserialize(WPSHOP_ATTRIBUTE_PRICES); |
| 228 | 228 | unset($price_tab[array_search(WPSHOP_COST_OF_POSTAGE, $price_tab)]); |
| 229 | - foreach($price_tab as $price_code){ |
|
| 229 | + foreach ($price_tab as $price_code) { |
|
| 230 | 230 | $query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code = %s", $price_code); |
| 231 | 231 | $attribute_id = $wpdb->get_var($query); |
| 232 | - switch($price_code){ |
|
| 232 | + switch ($price_code) { |
|
| 233 | 233 | case WPSHOP_PRODUCT_PRICE_HT: |
| 234 | - $position = ( WPSHOP_PRODUCT_PRICE_PILOT == 'HT' ) ? 1 : 3; |
|
| 234 | + $position = (WPSHOP_PRODUCT_PRICE_PILOT == 'HT') ? 1 : 3; |
|
| 235 | 235 | break; |
| 236 | 236 | case WPSHOP_PRODUCT_PRICE_TAX: |
| 237 | 237 | $position = 2; |
| 238 | 238 | break; |
| 239 | 239 | case WPSHOP_PRODUCT_PRICE_TTC: |
| 240 | - $position = ( WPSHOP_PRODUCT_PRICE_PILOT == 'HT' ) ? 3 : 1; |
|
| 240 | + $position = (WPSHOP_PRODUCT_PRICE_PILOT == 'HT') ? 3 : 1; |
|
| 241 | 241 | break; |
| 242 | 242 | case WPSHOP_PRODUCT_PRICE_TAX_AMOUNT: |
| 243 | 243 | $position = 4; |
@@ -256,47 +256,47 @@ discard block |
||
| 256 | 256 | /************ CHANGE THE FIELD NAME TO TAKE TO DISPLAY *************/ |
| 257 | 257 | /************ CHANGE ERROR MESSAGE FOR SPECIFIC CASE *************/ |
| 258 | 258 | /****************************************************************************/ |
| 259 | - if($actionResult != ''){ |
|
| 259 | + if ($actionResult != '') { |
|
| 260 | 260 | $elementIdentifierForMessage = __('the attribute group', 'wpshop'); |
| 261 | - if(!empty($attribute_set_parameter['name']))$elementIdentifierForMessage = '<span class="bold" >' . $attribute_set_parameter['name'] . '</span>'; |
|
| 262 | - if($actionResult == 'error'){/* CHANGE HERE FOR SPECIFIC CASE */ |
|
| 261 | + if (!empty($attribute_set_parameter['name']))$elementIdentifierForMessage = '<span class="bold" >' . $attribute_set_parameter['name'] . '</span>'; |
|
| 262 | + if ($actionResult == 'error') {/* CHANGE HERE FOR SPECIFIC CASE */ |
|
| 263 | 263 | $pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . sprintf(__('An error occured while saving %s', 'wpshop'), $elementIdentifierForMessage); |
| 264 | 264 | } |
| 265 | - elseif(($actionResult == 'done') || ($actionResult == 'nothingToUpdate')){ |
|
| 265 | + elseif (($actionResult == 'done') || ($actionResult == 'nothingToUpdate')) { |
|
| 266 | 266 | /*****************************************************************************************************************/ |
| 267 | 267 | /************************* CHANGE FOR SPECIFIC ACTION FOR CURRENT ELEMENT ******************/ |
| 268 | 268 | /*****************************************************************************************************************/ |
| 269 | - $wpshop_attribute_set_section_order = !empty( $_POST['wpshop_attribute_set_section_order'] ) ? (array)$_POST['wpshop_attribute_set_section_order'] : array(); |
|
| 270 | - $wpshop_attribute_set_section = !empty( $_POST['wpshop_attribute_set_section'] ) ? (array)$_POST['wpshop_attribute_set_section'] : array(); |
|
| 271 | - if ( !empty($wpshop_attribute_set_section_order) ) { |
|
| 269 | + $wpshop_attribute_set_section_order = !empty($_POST['wpshop_attribute_set_section_order']) ? (array)$_POST['wpshop_attribute_set_section_order'] : array(); |
|
| 270 | + $wpshop_attribute_set_section = !empty($_POST['wpshop_attribute_set_section']) ? (array)$_POST['wpshop_attribute_set_section'] : array(); |
|
| 271 | + if (!empty($wpshop_attribute_set_section_order)) { |
|
| 272 | 272 | $newOrder = str_replace('attribute_group_', '', $wpshop_attribute_set_section_order); |
| 273 | 273 | $order = explode(',', $newOrder); |
| 274 | - foreach($order as $position => $set_section_id){ |
|
| 275 | - $wpshop_attribute_set_section[$set_section_id]['position']=$position; |
|
| 274 | + foreach ($order as $position => $set_section_id) { |
|
| 275 | + $wpshop_attribute_set_section[$set_section_id]['position'] = $position; |
|
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | - $attribute_group_order = !empty( $_REQUEST['attribute_group_order'] ) ? (array)$_REQUEST['attribute_group_order'] : array(); |
|
| 280 | - if(isset($attribute_group_order)){ |
|
| 281 | - foreach($attribute_group_order as $groupIdentifier => $newOrder){ |
|
| 279 | + $attribute_group_order = !empty($_REQUEST['attribute_group_order']) ? (array)$_REQUEST['attribute_group_order'] : array(); |
|
| 280 | + if (isset($attribute_group_order)) { |
|
| 281 | + foreach ($attribute_group_order as $groupIdentifier => $newOrder) { |
|
| 282 | 282 | $newOrder = str_replace('attribute_', '', $newOrder); |
| 283 | 283 | $order = explode(',', $newOrder); |
| 284 | 284 | $groupId = str_replace('newOrder', '', $groupIdentifier); |
| 285 | 285 | $i = 1; |
| 286 | - foreach($order as $element){ |
|
| 287 | - if($element != ''){ |
|
| 288 | - if((int)$groupId > 0){ |
|
| 286 | + foreach ($order as $element) { |
|
| 287 | + if ($element != '') { |
|
| 288 | + if ((int)$groupId > 0) { |
|
| 289 | 289 | $query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " WHERE attribute_id = %d AND status = %s AND attribute_set_id = %d", $element, 'valid', $id); |
| 290 | 290 | $validElement = $wpdb->get_var($query); |
| 291 | - if(!empty($validElement)){ |
|
| 291 | + if (!empty($validElement)) { |
|
| 292 | 292 | $query = $wpdb->prepare("UPDATE " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " SET position = %d, attribute_group_id = %d, last_update_date = NOW() WHERE attribute_id = %d AND status = %s AND attribute_set_id = %d", $i, $groupId, $element, 'valid', $id); |
| 293 | 293 | } |
| 294 | - else{ |
|
| 294 | + else { |
|
| 295 | 295 | $query = $wpdb->prepare("INSERT INTO " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " (id, status, creation_date, entity_type_id, attribute_set_id, attribute_group_id, attribute_id, position) VALUES ('', 'valid', NOW(), %d, %d, %d, %d, %d)", $attribute_set_parameter['entity_id'], $id, $groupId, $element, $i); |
| 296 | 296 | } |
| 297 | 297 | $wpdb->query($query); |
| 298 | 298 | } |
| 299 | - else{ |
|
| 299 | + else { |
|
| 300 | 300 | $wpdb->update(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'deleted', 'last_update_date' => current_time('mysql', 0), 'position' => 0), array('attribute_id' => $element, 'status' => 'valid', 'attribute_set_id' => $id)); |
| 301 | 301 | } |
| 302 | 302 | $i++; |
@@ -305,10 +305,10 @@ discard block |
||
| 305 | 305 | } |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | - $wpshop_attribute_set_section_is_default_of_set = !empty( $_REQUEST['wpshop_attribute_set_section_is_default_of_set'] ) ? sanitize_key( $_REQUEST['wpshop_attribute_set_section_is_default_of_set'] ) : ''; |
|
| 309 | - if(!empty($wpshop_attribute_set_section)){ |
|
| 310 | - foreach($wpshop_attribute_set_section as $set_section_id => $set_section_options){ |
|
| 311 | - if(!empty($set_section_options) && is_array($set_section_options)){ |
|
| 308 | + $wpshop_attribute_set_section_is_default_of_set = !empty($_REQUEST['wpshop_attribute_set_section_is_default_of_set']) ? sanitize_key($_REQUEST['wpshop_attribute_set_section_is_default_of_set']) : ''; |
|
| 309 | + if (!empty($wpshop_attribute_set_section)) { |
|
| 310 | + foreach ($wpshop_attribute_set_section as $set_section_id => $set_section_options) { |
|
| 311 | + if (!empty($set_section_options) && is_array($set_section_options)) { |
|
| 312 | 312 | $set_section_options['default_group'] = (!empty($wpshop_attribute_set_section_is_default_of_set) && $wpshop_attribute_set_section_is_default_of_set == $set_section_id) ? 'yes' : 'no'; |
| 313 | 313 | $set_section_options['last_update_date'] = current_time('mysql', 0); |
| 314 | 314 | $set_section_options['display_on_frontend'] = (!empty($set_section_options['display_on_frontend']) && ($set_section_options['display_on_frontend'] == 'yes')) ? 'yes' : 'no'; |
@@ -317,9 +317,9 @@ discard block |
||
| 317 | 317 | } |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | - if ( !empty( $set_section ) ) { |
|
| 320 | + if (!empty($set_section)) { |
|
| 321 | 321 | $parent_attribute_set_detail = self::getAttributeSetDetails($set_section, "'valid'"); |
| 322 | - if ( !empty($parent_attribute_set_detail) ) { |
|
| 322 | + if (!empty($parent_attribute_set_detail)) { |
|
| 323 | 323 | |
| 324 | 324 | foreach ($parent_attribute_set_detail as $section => $section_detail) { |
| 325 | 325 | $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_GROUP, array('status'=>'valid', 'attribute_set_id' => $id, 'creation_date'=>current_time('mysql', 0), 'code'=>$section_detail['code'], 'name'=>$section_detail['name'], 'default_group'=>$section_detail['is_default_group'], 'backend_display_type'=>$section_detail['backend_display_type'], 'used_in_shop_type'=>$section_detail['used_in_shop_type'], 'display_on_frontend'=>$section_detail['display_on_frontend'])); |
@@ -332,17 +332,17 @@ discard block |
||
| 332 | 332 | } |
| 333 | 333 | } |
| 334 | 334 | |
| 335 | - $attribute_set_group_id = !empty( $_REQUEST['attribute_set_group_id'] ) ? (int) $_REQUEST['attribute_set_group_id'] : 0; |
|
| 335 | + $attribute_set_group_id = !empty($_REQUEST['attribute_set_group_id']) ? (int)$_REQUEST['attribute_set_group_id'] : 0; |
|
| 336 | 336 | /* If the current group is selected as default group set all others for current entity at no */ |
| 337 | - if($attribute_set_parameter['default_set'] == 'yes'){ |
|
| 337 | + if ($attribute_set_parameter['default_set'] == 'yes') { |
|
| 338 | 338 | $entity_to_take = 0; |
| 339 | - if(isset($attribute_set_group_id) && ($attribute_set_group_id != '')){ |
|
| 339 | + if (isset($attribute_set_group_id) && ($attribute_set_group_id != '')) { |
|
| 340 | 340 | $entity_to_take = $attribute_set_group_id; |
| 341 | 341 | } |
| 342 | - if(isset($attribute_set_parameter['entity_id']) && ($attribute_set_parameter['entity_id'] != '')){ |
|
| 342 | + if (isset($attribute_set_parameter['entity_id']) && ($attribute_set_parameter['entity_id'] != '')) { |
|
| 343 | 343 | $entity_to_take = $attribute_set_parameter['entity_id']; |
| 344 | 344 | } |
| 345 | - if($entity_to_take > 0){ |
|
| 345 | + if ($entity_to_take > 0) { |
|
| 346 | 346 | $query = $wpdb->prepare("UPDATE " . self::getDbTable() . " SET default_set = 'no' WHERE id != %d AND entity_id = %d", $id, $entity_to_take); |
| 347 | 347 | $wpdb->query($query); |
| 348 | 348 | } |
@@ -353,12 +353,12 @@ discard block |
||
| 353 | 353 | $pageMessage .= '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully saved', 'wpshop'), $elementIdentifierForMessage); |
| 354 | 354 | /* if(($pageAction == 'edit') || ($pageAction == 'save')) |
| 355 | 355 | wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=saveok&saveditem=" . $id)); |
| 356 | - else */if($pageAction == 'add') |
|
| 357 | - wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page='.self::getListingSlug()."&action=edit&id=".$id)); |
|
| 358 | - elseif($pageAction == 'delete') |
|
| 359 | - wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page='.self::getListingSlug()."&action=deleteok&saveditem=" . $id)); |
|
| 356 | + else */if ($pageAction == 'add') |
|
| 357 | + wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=edit&id=" . $id)); |
|
| 358 | + elseif ($pageAction == 'delete') |
|
| 359 | + wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=deleteok&saveditem=" . $id)); |
|
| 360 | 360 | } |
| 361 | - elseif(($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete')) |
|
| 361 | + elseif (($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete')) |
|
| 362 | 362 | $pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . __('You are not allowed to do this action', 'wpshop'); |
| 363 | 363 | } |
| 364 | 364 | |
@@ -373,16 +373,16 @@ discard block |
||
| 373 | 373 | //Create an instance of our package class... |
| 374 | 374 | $wpshop_list_table = new wpshop_attributes_set_custom_List_table(); |
| 375 | 375 | //Fetch, prepare, sort, and filter our data... |
| 376 | - $status="'valid', 'moderated'"; |
|
| 376 | + $status = "'valid', 'moderated'"; |
|
| 377 | 377 | $attribute_set_list = array(); |
| 378 | - $attribute_group_status = !empty( $_REQUEST['attribute_groups_status'] ) ? sanitize_text_field( $_REQUEST['attribute_groups_status'] ) : ''; |
|
| 379 | - if(!empty($attribute_group_status)){ |
|
| 380 | - $status="'".$attribute_group_status."'"; |
|
| 378 | + $attribute_group_status = !empty($_REQUEST['attribute_groups_status']) ? sanitize_text_field($_REQUEST['attribute_groups_status']) : ''; |
|
| 379 | + if (!empty($attribute_group_status)) { |
|
| 380 | + $status = "'" . $attribute_group_status . "'"; |
|
| 381 | 381 | } |
| 382 | 382 | $attr_set_list = wpshop_attributes_set::getElement('', $status); |
| 383 | - $i=0; |
|
| 384 | - foreach($attr_set_list as $attr_set){ |
|
| 385 | - if(!empty($attr_set->id)){ |
|
| 383 | + $i = 0; |
|
| 384 | + foreach ($attr_set_list as $attr_set) { |
|
| 385 | + if (!empty($attr_set->id)) { |
|
| 386 | 386 | $attribute_set_list[$i]['id'] = $attr_set->id; |
| 387 | 387 | $attribute_set_list[$i]['name'] = $attr_set->name; |
| 388 | 388 | $attribute_set_list[$i]['status'] = $attr_set->status; |
@@ -390,18 +390,18 @@ discard block |
||
| 390 | 390 | $attribute_set_details = self::getAttributeSetDetails($attr_set->id, "'valid'"); |
| 391 | 391 | |
| 392 | 392 | $attribute_set_list[$i]['content'] = ''; |
| 393 | - if(!empty($attribute_set_details)){ |
|
| 394 | - foreach($attribute_set_details as $set_details){ |
|
| 395 | - $attribute_set_list[$i]['content'] .= '<div><a href="'.admin_url('admin.php?page='.self::getListingSlug()."&action=edit&id=".$attr_set->id.'#attribute_group_'.$set_details['id']).'" >'.__($set_details['name'],'wpshop').'</a> '; |
|
| 396 | - $has_att=false; |
|
| 397 | - foreach($set_details['attribut'] as $set_detail){ |
|
| 398 | - if(!empty($set_detail->frontend_label) && ( $set_detail->code != 'product_attribute_set_id' ) ){ |
|
| 399 | - $attribute_set_list[$i]['content'] .= __($set_detail->frontend_label,'wpshop').', '; |
|
| 400 | - $has_att=true; |
|
| 393 | + if (!empty($attribute_set_details)) { |
|
| 394 | + foreach ($attribute_set_details as $set_details) { |
|
| 395 | + $attribute_set_list[$i]['content'] .= '<div><a href="' . admin_url('admin.php?page=' . self::getListingSlug() . "&action=edit&id=" . $attr_set->id . '#attribute_group_' . $set_details['id']) . '" >' . __($set_details['name'], 'wpshop') . '</a> '; |
|
| 396 | + $has_att = false; |
|
| 397 | + foreach ($set_details['attribut'] as $set_detail) { |
|
| 398 | + if (!empty($set_detail->frontend_label) && ($set_detail->code != 'product_attribute_set_id')) { |
|
| 399 | + $attribute_set_list[$i]['content'] .= __($set_detail->frontend_label, 'wpshop') . ', '; |
|
| 400 | + $has_att = true; |
|
| 401 | 401 | } |
| 402 | 402 | } |
| 403 | - if(!empty($attribute_set_list[$i]['content'])){ |
|
| 404 | - if($has_att)$attribute_set_list[$i]['content'] = substr($attribute_set_list[$i]['content'],0,-2); |
|
| 403 | + if (!empty($attribute_set_list[$i]['content'])) { |
|
| 404 | + if ($has_att)$attribute_set_list[$i]['content'] = substr($attribute_set_list[$i]['content'], 0, -2); |
|
| 405 | 405 | $attribute_set_list[$i]['content'] .= '</div>'; |
| 406 | 406 | } |
| 407 | 407 | } |
@@ -440,45 +440,45 @@ discard block |
||
| 440 | 440 | $dbFieldList = wpshop_database::fields_to_input(self::getDbTable()); |
| 441 | 441 | $form_more_content = $the_form_content_hidden = $the_form_general_content = ''; |
| 442 | 442 | $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : 'add'; |
| 443 | - $bloc_list=array(); |
|
| 443 | + $bloc_list = array(); |
|
| 444 | 444 | |
| 445 | 445 | $editedItem = ''; |
| 446 | - if($itemToEdit != '') |
|
| 446 | + if ($itemToEdit != '') |
|
| 447 | 447 | $editedItem = self::getElement($itemToEdit); |
| 448 | 448 | |
| 449 | - foreach($dbFieldList as $input_key => $input_def){ |
|
| 449 | + foreach ($dbFieldList as $input_key => $input_def) { |
|
| 450 | 450 | $input_name = $input_def['name']; |
| 451 | 451 | $input_value = $input_def['value']; |
| 452 | - $input_def_id=$input_def['id']='wpshop_' . self::currentPageCode . '_edition_table_field_id_'.$input_name; |
|
| 452 | + $input_def_id = $input_def['id'] = 'wpshop_' . self::currentPageCode . '_edition_table_field_id_' . $input_name; |
|
| 453 | 453 | |
| 454 | 454 | $attributeAction = isset($_REQUEST[self::getDbTable() . '_action']) ? sanitize_text_field($_REQUEST[self::getDbTable() . '_action']) : ''; |
| 455 | 455 | $attributeFormValue = isset($_REQUEST[self::getDbTable()][$input_name]) ? sanitize_text_field($_REQUEST[self::getDbTable()][$input_name]) : ''; |
| 456 | 456 | |
| 457 | 457 | /* Get value by checking current object type */ |
| 458 | 458 | $currentFieldValue = $input_value; |
| 459 | - if(is_object($editedItem)) |
|
| 459 | + if (is_object($editedItem)) |
|
| 460 | 460 | $currentFieldValue = $editedItem->$input_name; |
| 461 | - elseif(($attributeAction != '') && ($attributeFormValue != '')) |
|
| 461 | + elseif (($attributeAction != '') && ($attributeFormValue != '')) |
|
| 462 | 462 | $currentFieldValue = $attributeFormValue; |
| 463 | 463 | |
| 464 | 464 | /* Check if the field must be hidden */ |
| 465 | - if(in_array($input_name, $attribute_hidden_field)) |
|
| 465 | + if (in_array($input_name, $attribute_hidden_field)) |
|
| 466 | 466 | $input_def['type'] = 'hidden'; |
| 467 | 467 | if ($input_name == 'entity_id') { |
| 468 | 468 | $input_def['type'] = 'select'; |
| 469 | 469 | $input_def['possible_value'] = wpshop_entities::get_entities_list(); |
| 470 | 470 | |
| 471 | 471 | $input_def['valueToPut'] = 'index'; |
| 472 | - if ( is_object($editedItem) || (count($input_def['possible_value'])==1) ) { |
|
| 472 | + if (is_object($editedItem) || (count($input_def['possible_value']) == 1)) { |
|
| 473 | 473 | $input_def['type'] = 'hidden'; |
| 474 | - $currentFieldValue=(count($input_def['possible_value'])==1)?$input_def['possible_value'][0]->id:$currentFieldValue; |
|
| 474 | + $currentFieldValue = (count($input_def['possible_value']) == 1) ? $input_def['possible_value'][0]->id : $currentFieldValue; |
|
| 475 | 475 | } |
| 476 | 476 | $input_def['name'] = $input_name; |
| 477 | 477 | $input_def['value'] = $currentFieldValue; |
| 478 | 478 | |
| 479 | - $i=0; |
|
| 480 | - foreach($input_def['possible_value'] as $entity_id => $entity_name) { |
|
| 481 | - if($i <= 0){ |
|
| 479 | + $i = 0; |
|
| 480 | + foreach ($input_def['possible_value'] as $entity_id => $entity_name) { |
|
| 481 | + if ($i <= 0) { |
|
| 482 | 482 | $current_entity_id = $entity_id; |
| 483 | 483 | } |
| 484 | 484 | $i++; |
@@ -487,19 +487,19 @@ discard block |
||
| 487 | 487 | $the_input = wpshop_form::check_input_type($input_def, self::getDbTable()); |
| 488 | 488 | } |
| 489 | 489 | else { |
| 490 | - if(in_array($input_name, array('status', 'default_set'))){ |
|
| 490 | + if (in_array($input_name, array('status', 'default_set'))) { |
|
| 491 | 491 | $input_def['type'] = 'checkbox'; |
| 492 | - switch($input_name){ |
|
| 492 | + switch ($input_name) { |
|
| 493 | 493 | case 'status': |
| 494 | 494 | $input_name = __('Use this attribute group', 'wpshop'); |
| 495 | 495 | $input_def['possible_value'] = array('valid'); |
| 496 | - $input_def_id.='_valid'; |
|
| 497 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for using this attribute group', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 496 | + $input_def_id .= '_valid'; |
|
| 497 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for using this attribute group', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 498 | 498 | break; |
| 499 | 499 | case 'default_set': |
| 500 | 500 | $input_def['possible_value'] = array('yes'); |
| 501 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for using this attribute group as default group in selected element', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 502 | - $input_def_id.='_yes'; |
|
| 501 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for using this attribute group as default group in selected element', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 502 | + $input_def_id .= '_yes'; |
|
| 503 | 503 | break; |
| 504 | 504 | } |
| 505 | 505 | } |
@@ -507,61 +507,61 @@ discard block |
||
| 507 | 507 | $the_input = wpshop_form::check_input_type($input_def, self::getDbTable()); |
| 508 | 508 | } |
| 509 | 509 | |
| 510 | - if($input_def['type'] != 'hidden'){ |
|
| 510 | + if ($input_def['type'] != 'hidden') { |
|
| 511 | 511 | $the_form_general_content .= ' |
| 512 | - <tr class="wpshop_' . self::currentPageCode . '_edition_table_line wpshop_' . self::currentPageCode . '_edition_table_line_'.$input_name.'" > |
|
| 513 | - <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_'.$input_name.'" ><label for="'.$input_def_id.'" >' . __($input_name, 'wpshop') . '</label></td> |
|
| 514 | - <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_input wpshop_' . self::currentPageCode . '_edition_table_field_input_'.$input_name.'" >' . $the_input . '</td> |
|
| 512 | + <tr class="wpshop_' . self::currentPageCode . '_edition_table_line wpshop_' . self::currentPageCode . '_edition_table_line_' . $input_name . '" > |
|
| 513 | + <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_' . $input_name . '" ><label for="' . $input_def_id . '" >' . __($input_name, 'wpshop') . '</label></td> |
|
| 514 | + <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_input wpshop_' . self::currentPageCode . '_edition_table_field_input_' . $input_name . '" >' . $the_input . '</td> |
|
| 515 | 515 | </tr>'; |
| 516 | 516 | } |
| 517 | - else{ |
|
| 517 | + else { |
|
| 518 | 518 | $the_form_content_hidden .= ' |
| 519 | 519 | ' . $the_input; |
| 520 | 520 | } |
| 521 | 521 | } |
| 522 | 522 | |
| 523 | - if( empty($itemToEdit) ) { |
|
| 524 | - $the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id, self::getDbTable(), self::currentPageCode, false); |
|
| 523 | + if (empty($itemToEdit)) { |
|
| 524 | + $the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id, self::getDbTable(), self::currentPageCode, false); |
|
| 525 | 525 | $the_form_general_content .= ' |
| 526 | 526 | <tr class="wpshop_' . self::currentPageCode . '_edition_table_line wpshop_' . self::currentPageCode . '_edition_table_line_existing_attribute_set_copy_from" > |
| 527 | - <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_existing_attribute_set_copy_from" ><label for="'.$input_def_id.'" >' . __('Create the new group from an existing', 'wpshop') . '</label></td> |
|
| 527 | + <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_existing_attribute_set_copy_from" ><label for="' . $input_def_id . '" >' . __('Create the new group from an existing', 'wpshop') . '</label></td> |
|
| 528 | 528 | <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_input wpshop_' . self::currentPageCode . '_edition_table_field_input_existing_attribute_set_copy_from" >' . $the_input . '</td> |
| 529 | 529 | </tr>'; |
| 530 | 530 | } |
| 531 | 531 | $the_form_general_content = ' |
| 532 | 532 | <table class="wpshop_' . self::currentPageCode . '_edition_table wpshop_' . self::currentPageCode . '_edition_table_main_info" > |
| 533 | -'.$the_form_general_content.' |
|
| 533 | +'.$the_form_general_content . ' |
|
| 534 | 534 | </table>'; |
| 535 | 535 | |
| 536 | 536 | /* Default content for the current page */ |
| 537 | - $bloc_list[self::currentPageCode]['main_info']['title']=__('Main informations', 'wpshop'); |
|
| 538 | - $bloc_list[self::currentPageCode]['main_info']['content']=$the_form_general_content; |
|
| 537 | + $bloc_list[self::currentPageCode]['main_info']['title'] = __('Main informations', 'wpshop'); |
|
| 538 | + $bloc_list[self::currentPageCode]['main_info']['content'] = $the_form_general_content; |
|
| 539 | 539 | |
| 540 | - if(is_object($editedItem)){ |
|
| 541 | - $bloc_list[self::currentPageCode]['detail']['title']=__('Attribute group section details', 'wpshop'); |
|
| 542 | - $bloc_list[self::currentPageCode]['detail']['content']=self::attributeSetDetailsManagement($itemToEdit); |
|
| 540 | + if (is_object($editedItem)) { |
|
| 541 | + $bloc_list[self::currentPageCode]['detail']['title'] = __('Attribute group section details', 'wpshop'); |
|
| 542 | + $bloc_list[self::currentPageCode]['detail']['content'] = self::attributeSetDetailsManagement($itemToEdit); |
|
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | $the_form = ' |
| 546 | 546 | <form name="' . self::getDbTable() . '_form" id="' . self::getDbTable() . '_form" method="post" action="#" > |
| 547 | -' . wpshop_form::form_input(self::getDbTable() . '_action', self::getDbTable() . '_action', (!empty($_REQUEST['action'])?sanitize_text_field($_REQUEST['action']):'save'), 'hidden') . ' |
|
| 548 | -' . wpshop_form::form_input(self::getDbTable() . '_form_has_modification', self::getDbTable() . '_form_has_modification', 'no' , 'hidden') . $the_form_content_hidden . wpshop_display::custom_page_output_builder($bloc_list, WPSHOP_ATTRIBUTE_SET_EDITION_PAGE_LAYOUT) . ' |
|
| 549 | - <div class="wpshop_edition_button wpshop_edition_button_'.self::currentPageCode.'" >'; |
|
| 547 | +' . wpshop_form::form_input(self::getDbTable() . '_action', self::getDbTable() . '_action', (!empty($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : 'save'), 'hidden') . ' |
|
| 548 | +' . wpshop_form::form_input(self::getDbTable() . '_form_has_modification', self::getDbTable() . '_form_has_modification', 'no', 'hidden') . $the_form_content_hidden . wpshop_display::custom_page_output_builder($bloc_list, WPSHOP_ATTRIBUTE_SET_EDITION_PAGE_LAYOUT) . ' |
|
| 549 | + <div class="wpshop_edition_button wpshop_edition_button_'.self::currentPageCode . '" >'; |
|
| 550 | 550 | |
| 551 | - if(($action == 'add') && (current_user_can('wpshop_add_attribute_set'))) |
|
| 551 | + if (($action == 'add') && (current_user_can('wpshop_add_attribute_set'))) |
|
| 552 | 552 | $the_form .= '<input type="submit" class="button-primary" id="add" name="add" value="' . __('Add', 'wpshop') . '" />'; |
| 553 | - elseif(current_user_can('wpshop_edit_attribute_set')) |
|
| 553 | + elseif (current_user_can('wpshop_edit_attribute_set')) |
|
| 554 | 554 | $the_form .= '<input type="submit" class="button-primary" id="save" name="save" value="' . __('Save', 'wpshop') . '" />'; |
| 555 | 555 | |
| 556 | - if(current_user_can('wpshop_delete_attribute_set') && ($action != 'add')) |
|
| 557 | - $the_form .= '<input type="button" class="button-secondary wpshop_delete_element_button wpshop_delete_element_button_'.self::currentPageCode.'" id="delete" name="delete" value="' . __('Delete', 'wpshop') . '" />'; |
|
| 556 | + if (current_user_can('wpshop_delete_attribute_set') && ($action != 'add')) |
|
| 557 | + $the_form .= '<input type="button" class="button-secondary wpshop_delete_element_button wpshop_delete_element_button_' . self::currentPageCode . '" id="delete" name="delete" value="' . __('Delete', 'wpshop') . '" />'; |
|
| 558 | 558 | |
| 559 | 559 | $the_form .= ' |
| 560 | 560 | </div> |
| 561 | 561 | </form> |
| 562 | 562 | <script type="text/javascript" > |
| 563 | 563 | wpshop(document).ready(function(){ |
| 564 | - wpshopMainInterface("'.self::getDbTable().'", "' . __('Are you sure you want to quit this page? You will loose all current modification', 'wpshop') . '", "' . __('Are you sure you want to delete this attributes group?', 'wpshop') . '"); |
|
| 564 | + wpshopMainInterface("'.self::getDbTable() . '", "' . __('Are you sure you want to quit this page? You will loose all current modification', 'wpshop') . '", "' . __('Are you sure you want to delete this attributes group?', 'wpshop') . '"); |
|
| 565 | 565 | |
| 566 | 566 | jQuery("#wpshop_attribute_set_edition_table_field_id_entity_id").change(function(){ |
| 567 | 567 | jQuery(".wpshop_attribute_set_edition_table_field_input_existing_attribute_set_copy_from").html(jQuery("#wpshopLoadingPicture").html()); |
@@ -585,7 +585,7 @@ discard block |
||
| 585 | 585 | * |
| 586 | 586 | * @return string $currentPageButton The html output code with the different button to add to the interface |
| 587 | 587 | */ |
| 588 | - function getPageFormButton($element_id = 0){ |
|
| 588 | + function getPageFormButton($element_id = 0) { |
|
| 589 | 589 | $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : 'add'; |
| 590 | 590 | $currentPageButton = ''; |
| 591 | 591 | |
@@ -600,15 +600,15 @@ discard block |
||
| 600 | 600 | * |
| 601 | 601 | * @return object $elements A wordpress database object containing the element list |
| 602 | 602 | */ |
| 603 | - public static function getElement($elementId = '', $elementStatus = "'valid', 'moderated'", $whatToSearch = 'id', $resultList = '', $entity_id = ''){ |
|
| 603 | + public static function getElement($elementId = '', $elementStatus = "'valid', 'moderated'", $whatToSearch = 'id', $resultList = '', $entity_id = '') { |
|
| 604 | 604 | global $wpdb; |
| 605 | 605 | $elements = array(); |
| 606 | 606 | $moreQuery = ""; |
| 607 | 607 | $moreQueryArgs = array(); |
| 608 | 608 | |
| 609 | - if($elementId != '') |
|
| 609 | + if ($elementId != '') |
|
| 610 | 610 | { |
| 611 | - switch($whatToSearch) |
|
| 611 | + switch ($whatToSearch) |
|
| 612 | 612 | { |
| 613 | 613 | case 'entity_code': |
| 614 | 614 | $moreQuery = " |
@@ -638,13 +638,13 @@ discard block |
||
| 638 | 638 | $moreQueryArgs[] = $elementId; |
| 639 | 639 | } |
| 640 | 640 | |
| 641 | - if ( !empty($entity_id) ) { |
|
| 641 | + if (!empty($entity_id)) { |
|
| 642 | 642 | $moreQuery .= " |
| 643 | 643 | AND ATTRIBUTE_SET.entity_id = %d "; |
| 644 | 644 | $moreQueryArgs[] = $entity_id; |
| 645 | 645 | } |
| 646 | 646 | |
| 647 | - if( empty($entity_id) ) { |
|
| 647 | + if (empty($entity_id)) { |
|
| 648 | 648 | $moreQuery .= "AND 1=%d"; |
| 649 | 649 | $moreQueryArgs[] = 1; |
| 650 | 650 | } |
@@ -653,11 +653,11 @@ discard block |
||
| 653 | 653 | "SELECT ATTRIBUTE_SET.*, ENTITIES.post_name as entity |
| 654 | 654 | FROM " . self::getDbTable() . " AS ATTRIBUTE_SET |
| 655 | 655 | INNER JOIN " . $wpdb->posts . " AS ENTITIES ON (ENTITIES.ID = ATTRIBUTE_SET.entity_id) |
| 656 | - WHERE ATTRIBUTE_SET.status IN (".$elementStatus.") " . $moreQuery, $moreQueryArgs |
|
| 656 | + WHERE ATTRIBUTE_SET.status IN (".$elementStatus . ") " . $moreQuery, $moreQueryArgs |
|
| 657 | 657 | ); |
| 658 | 658 | |
| 659 | 659 | /* Get the query result regarding on the function parameters. If there must be only one result or a collection */ |
| 660 | - if(($elementId == '') || ($resultList == 'all')) |
|
| 660 | + if (($elementId == '') || ($resultList == 'all')) |
|
| 661 | 661 | { |
| 662 | 662 | $elements = $wpdb->get_results($query); |
| 663 | 663 | } |
@@ -676,21 +676,21 @@ discard block |
||
| 676 | 676 | * |
| 677 | 677 | * @return string $attributeSetDetailsManagement The html output of management interface |
| 678 | 678 | */ |
| 679 | - public static function attributeSetDetailsManagement($attributeSetId = ''){ |
|
| 679 | + public static function attributeSetDetailsManagement($attributeSetId = '') { |
|
| 680 | 680 | global $validAttributeList; global $wpdb; |
| 681 | 681 | $user_more_script = $add_button = ''; |
| 682 | 682 | $end_line_display = array(); |
| 683 | 683 | /** Check if it's billing or Shipping **/ |
| 684 | - if ( !empty($attributeSetId) ) { |
|
| 685 | - $shipping_option = get_option( 'wpshop_shipping_address_choice' ); |
|
| 686 | - $billing_option = get_option( 'wpshop_billing_address' ); |
|
| 684 | + if (!empty($attributeSetId)) { |
|
| 685 | + $shipping_option = get_option('wpshop_shipping_address_choice'); |
|
| 686 | + $billing_option = get_option('wpshop_billing_address'); |
|
| 687 | 687 | |
| 688 | - if ( !empty($shipping_option) && !empty($shipping_option['choice']) && $shipping_option['choice'] == $attributeSetId ) { |
|
| 689 | - $end_line_display = ( !empty( $shipping_option['display_model'] ) ) ? $shipping_option['display_model'] : array(); |
|
| 688 | + if (!empty($shipping_option) && !empty($shipping_option['choice']) && $shipping_option['choice'] == $attributeSetId) { |
|
| 689 | + $end_line_display = (!empty($shipping_option['display_model'])) ? $shipping_option['display_model'] : array(); |
|
| 690 | 690 | } |
| 691 | 691 | |
| 692 | - if ( !empty($billing_option) && !empty($billing_option['choice']) && $billing_option['choice'] == $attributeSetId ) { |
|
| 693 | - $end_line_display = ( !empty( $billing_option['display_model'] ) ) ? $billing_option['display_model'] : array(); |
|
| 692 | + if (!empty($billing_option) && !empty($billing_option['choice']) && $billing_option['choice'] == $attributeSetId) { |
|
| 693 | + $end_line_display = (!empty($billing_option['display_model'])) ? $billing_option['display_model'] : array(); |
|
| 694 | 694 | } |
| 695 | 695 | } |
| 696 | 696 | |
@@ -698,12 +698,12 @@ discard block |
||
| 698 | 698 | |
| 699 | 699 | $attributeSetDetailsManagement = ' |
| 700 | 700 | <div id="managementContainer" >'; |
| 701 | - if(current_user_can('wpshop_add_attribute_group')){ |
|
| 701 | + if (current_user_can('wpshop_add_attribute_group')) { |
|
| 702 | 702 | $dialog_title = __('New attribute set section name', 'wpshop'); |
| 703 | 703 | $dialog_identifier = 'wpshop_new_set_section_add'; |
| 704 | 704 | $dialog_input_identifier = 'wpshop_new_attribute_set_section_name'; |
| 705 | 705 | ob_start(); |
| 706 | - include(WPSHOP_TEMPLATES_DIR.'admin/add_new_element_dialog.tpl.php'); |
|
| 706 | + include(WPSHOP_TEMPLATES_DIR . 'admin/add_new_element_dialog.tpl.php'); |
|
| 707 | 707 | $attributeSetDetailsManagement .= ob_get_contents(); |
| 708 | 708 | ob_end_clean(); |
| 709 | 709 | |
@@ -711,37 +711,37 @@ discard block |
||
| 711 | 711 | $add_button_parent_class = 'attribute_set_section_add_new_button'; |
| 712 | 712 | $add_button_name = 'wpshop_create_new_set_section_top'; |
| 713 | 713 | ob_start(); |
| 714 | - include(WPSHOP_TEMPLATES_DIR.'admin/add_new_element_with_dialog.tpl.php'); |
|
| 714 | + include(WPSHOP_TEMPLATES_DIR . 'admin/add_new_element_with_dialog.tpl.php'); |
|
| 715 | 715 | $add_button = ob_get_contents(); |
| 716 | 716 | ob_end_clean(); |
| 717 | 717 | |
| 718 | 718 | $user_more_script .= ' |
| 719 | - jQuery("#'.$dialog_identifier.'").dialog({ |
|
| 719 | + jQuery("#'.$dialog_identifier . '").dialog({ |
|
| 720 | 720 | modal: true, |
| 721 | 721 | dialogClass: "wpshop_uidialog_box", |
| 722 | 722 | autoOpen:false, |
| 723 | 723 | show: "blind", |
| 724 | 724 | resizable: false, |
| 725 | 725 | buttons:{ |
| 726 | - "'.__('Add', 'wpshop').'": function(){ |
|
| 726 | + "'.__('Add', 'wpshop') . '": function(){ |
|
| 727 | 727 | jQuery("#managementContainer").load(ajaxurl,{ |
| 728 | 728 | "action": "wps_attribute_set_section_new", |
| 729 | 729 | "_wpnonce": "' . wp_create_nonce("saveNewAttributeSetSection") . '", |
| 730 | 730 | "elementIdentifier": "' . $attributeSetId . '", |
| 731 | - "attributeSetSectionName": jQuery("#'.$dialog_input_identifier.'").val() |
|
| 731 | + "attributeSetSectionName": jQuery("#'.$dialog_input_identifier . '").val() |
|
| 732 | 732 | }); |
| 733 | 733 | jQuery(this).children("img").show(); |
| 734 | 734 | }, |
| 735 | - "'.__('Cancel', 'wpshop').'": function(){ |
|
| 735 | + "'.__('Cancel', 'wpshop') . '": function(){ |
|
| 736 | 736 | jQuery(this).dialog("close"); |
| 737 | 737 | } |
| 738 | 738 | }, |
| 739 | 739 | close:function(){ |
| 740 | - jQuery("#'.$dialog_input_identifier.'").val(""); |
|
| 740 | + jQuery("#'.$dialog_input_identifier . '").val(""); |
|
| 741 | 741 | } |
| 742 | 742 | }); |
| 743 | - jQuery(".'.$add_button_parent_class.' input").click(function(){ |
|
| 744 | - jQuery("#'.$dialog_identifier.'").dialog("open"); |
|
| 743 | + jQuery(".'.$add_button_parent_class . ' input").click(function(){ |
|
| 744 | + jQuery("#'.$dialog_identifier . '").dialog("open"); |
|
| 745 | 745 | });'; |
| 746 | 746 | } |
| 747 | 747 | $attributeSetDetailsManagement .= ' |
@@ -750,62 +750,62 @@ discard block |
||
| 750 | 750 | |
| 751 | 751 | /* Get information about the current attribute set we are editing */ |
| 752 | 752 | $attributeSetDetails = self::getAttributeSetDetails($attributeSetId); |
| 753 | - if(is_array($attributeSetDetails) && (count($attributeSetDetails) > 0)){ |
|
| 753 | + if (is_array($attributeSetDetails) && (count($attributeSetDetails) > 0)) { |
|
| 754 | 754 | /* Build output with the current attribute set details */ |
| 755 | - foreach($attributeSetDetails as $attributeSetIDGroup => $attributeSetDetailsGroup){ |
|
| 755 | + foreach ($attributeSetDetails as $attributeSetIDGroup => $attributeSetDetailsGroup) { |
|
| 756 | 756 | /* Check possible action for general code */ |
| 757 | 757 | $elementActionClass = 'wpshop_attr_set_section_name'; |
| 758 | 758 | $edition_area = $edit_button = ''; |
| 759 | - if ( current_user_can('wpshop_edit_attribute_group') ) { |
|
| 759 | + if (current_user_can('wpshop_edit_attribute_group')) { |
|
| 760 | 760 | $elementActionClass = 'wpshop_attr_set_section_name_editable'; |
| 761 | 761 | $edit_button = ' |
| 762 | - <a class="wpshop_attr_tool_box_button wpshop_attr_tool_box_edit wpshop_attr_tool_box_edit_attribute_set_section" id="wpshop_set_section_edit_'.$attributeSetDetailsGroup['id'].'" title="'.__('Edit this section', 'wpshop').'"></a>'; |
|
| 762 | + <a class="wpshop_attr_tool_box_button wpshop_attr_tool_box_edit wpshop_attr_tool_box_edit_attribute_set_section" id="wpshop_set_section_edit_'.$attributeSetDetailsGroup['id'] . '" title="' . __('Edit this section', 'wpshop') . '"></a>'; |
|
| 763 | 763 | |
| 764 | 764 | $tpl_component = array(); |
| 765 | 765 | $tpl_component['ADMIN_GROUP_IDENTIFIER'] = str_replace('-', '_', sanitize_title($attributeSetDetailsGroup['id'])); |
| 766 | 766 | $tpl_component['ADMIN_GROUP_ID'] = $attributeSetDetailsGroup['id']; |
| 767 | 767 | $tpl_component['ADMIN_GROUP_NAME'] = __($attributeSetDetailsGroup['name'], 'wpshop'); |
| 768 | - $tpl_component['ADMIN_GROUP_DISPLAY_TYPE_TAB'] = (!empty($attributeSetDetailsGroup['backend_display_type']) && ($attributeSetDetailsGroup['backend_display_type']=='fixed-tab')?' selected="selected"':''); |
|
| 769 | - $tpl_component['ADMIN_GROUP_DISPLAY_TYPE_BOX'] = (!empty($attributeSetDetailsGroup['backend_display_type']) && ($attributeSetDetailsGroup['backend_display_type']=='movable-tab')?' selected="selected"':''); |
|
| 770 | - $tpl_component['ADMIN_GROUP_DISPLAY_ON_FRONTEND'] = (!empty($attributeSetDetailsGroup['display_on_frontend']) && ($attributeSetDetailsGroup['display_on_frontend']=='yes')?' checked="checked"':''); |
|
| 768 | + $tpl_component['ADMIN_GROUP_DISPLAY_TYPE_TAB'] = (!empty($attributeSetDetailsGroup['backend_display_type']) && ($attributeSetDetailsGroup['backend_display_type'] == 'fixed-tab') ? ' selected="selected"' : ''); |
|
| 769 | + $tpl_component['ADMIN_GROUP_DISPLAY_TYPE_BOX'] = (!empty($attributeSetDetailsGroup['backend_display_type']) && ($attributeSetDetailsGroup['backend_display_type'] == 'movable-tab') ? ' selected="selected"' : ''); |
|
| 770 | + $tpl_component['ADMIN_GROUP_DISPLAY_ON_FRONTEND'] = (!empty($attributeSetDetailsGroup['display_on_frontend']) && ($attributeSetDetailsGroup['display_on_frontend'] == 'yes') ? ' checked="checked"' : ''); |
|
| 771 | 771 | $edition_area = wpshop_display::display_template_element('wpshop_admin_attr_set_section_params', $tpl_component, array(), 'admin'); |
| 772 | 772 | unset($tpl_component); |
| 773 | 773 | } |
| 774 | 774 | //<td rowspan="2" class="wpshop_attribute_set_section_detail_table_default_td" ><input title="'.__('Default section', 'wpshop').'" type="radio" name="wpshop_attribute_set_section_is_default_of_set" '.($is_default?'checked="checked" ':'').'id="wpshop_attribute_set_section_is_default_of_set_'.$attributeSetDetailsGroup['id'].'" value="'.$attributeSetDetailsGroup['id'].'" /></td> |
| 775 | - $is_default = (!empty($attributeSetDetailsGroup['is_default_group']) && ($attributeSetDetailsGroup['is_default_group']=='yes')?true:false); |
|
| 775 | + $is_default = (!empty($attributeSetDetailsGroup['is_default_group']) && ($attributeSetDetailsGroup['is_default_group'] == 'yes') ? true : false); |
|
| 776 | 776 | $attributeSetDetailsManagement .= ' |
| 777 | - <li id="attribute_group_' . $attributeSetIDGroup . '" class="attribute_set_section_container attribute_set_section_container_'.($is_default?'is_default':'normal').'" > |
|
| 777 | + <li id="attribute_group_' . $attributeSetIDGroup . '" class="attribute_set_section_container attribute_set_section_container_' . ($is_default ? 'is_default' : 'normal') . '" > |
|
| 778 | 778 | <table class="wpshpop_attribute_set_section_detail_table" > |
| 779 | 779 | <tr> |
| 780 | 780 | <td id="wpshop_attr_set_section_name_' . $attributeSetDetailsGroup['id'] . '" class="' . $elementActionClass . '" >' . __($attributeSetDetailsGroup['name'], 'wpshop') . '</td> |
| 781 | 781 | </tr> |
| 782 | 782 | <tr> |
| 783 | 783 | <td> |
| 784 | - <input class="newOrder" type="hidden" name="attribute_group_order[newOrder' . $attributeSetIDGroup . ']" id="newOrder' . $attributeSetIDGroup . '" value="' .( ( !empty($end_line_display) && !empty($end_line_display[$attributeSetIDGroup]) ) ? implode( ',', $end_line_display[$attributeSetIDGroup] ) : '' ). '" />'; |
|
| 784 | + <input class="newOrder" type="hidden" name="attribute_group_order[newOrder' . $attributeSetIDGroup . ']" id="newOrder' . $attributeSetIDGroup . '" value="' . ((!empty($end_line_display) && !empty($end_line_display[$attributeSetIDGroup])) ? implode(',', $end_line_display[$attributeSetIDGroup]) : '') . '" />'; |
|
| 785 | 785 | |
| 786 | 786 | /* Add the set section details */ |
| 787 | 787 | $price_tab = unserialize(WPSHOP_ATTRIBUTE_PRICES); |
| 788 | 788 | unset($price_tab[array_search(WPSHOP_COST_OF_POSTAGE, $price_tab)]); |
| 789 | 789 | $no_delete_button = false; |
| 790 | - if ( is_array($attributeSetDetailsGroup['attribut']) && (count($attributeSetDetailsGroup['attribut']) >= 1) ) { |
|
| 790 | + if (is_array($attributeSetDetailsGroup['attribut']) && (count($attributeSetDetailsGroup['attribut']) >= 1)) { |
|
| 791 | 791 | $attributeSetDetailsManagement .= ' |
| 792 | 792 | <ul id="attribute_group_' . $attributeSetIDGroup . '_details" class="wpshop_attr_set_section_details" >'; |
| 793 | 793 | ksort($attributeSetDetailsGroup['attribut']); |
| 794 | 794 | $end_line_id = 0; |
| 795 | - foreach ( $attributeSetDetailsGroup['attribut'] as $attributInGroup ) { |
|
| 796 | - if ( in_array($attributInGroup->code, $price_tab) ){ |
|
| 795 | + foreach ($attributeSetDetailsGroup['attribut'] as $attributInGroup) { |
|
| 796 | + if (in_array($attributInGroup->code, $price_tab)) { |
|
| 797 | 797 | $no_delete_button = true; |
| 798 | 798 | } |
| 799 | - if ( !empty($attributInGroup->id) && ( $attributInGroup->code != 'product_attribute_set_id' ) ) { |
|
| 799 | + if (!empty($attributInGroup->id) && ($attributInGroup->code != 'product_attribute_set_id')) { |
|
| 800 | 800 | |
| 801 | 801 | $attributeSetDetailsManagement .= ' |
| 802 | - <li class="ui-state-default attribute' . (in_array($attributInGroup->code, $price_tab) ? ' ui-state-disabled' : '') . '" id="attribute_' . $attributInGroup->id . '" >' . __($attributInGroup->frontend_label, 'wpshop') . '</li>'; |
|
| 802 | + <li class="ui-state-default attribute' . (in_array($attributInGroup->code, $price_tab) ? ' ui-state-disabled' : '') . '" id="attribute_' . $attributInGroup->id . '" >' . __($attributInGroup->frontend_label, 'wpshop') . '</li>'; |
|
| 803 | 803 | |
| 804 | 804 | |
| 805 | - if ( !empty($end_line_display) && !empty($end_line_display[ $attributeSetIDGroup ]) && in_array('attribute_' .$attributInGroup->id, $end_line_display[ $attributeSetIDGroup ]) ) { |
|
| 806 | - $key = array_search('attribute_' .$attributInGroup->id, $end_line_display[ $attributeSetIDGroup ] ); |
|
| 807 | - if ( !empty($end_line_display[ $attributeSetIDGroup ][$key + 1]) && $end_line_display[ $attributeSetIDGroup ][$key + 1] == 'wps-attribute-end-line-'.$end_line_id ) { |
|
| 808 | - $attributeSetDetailsManagement .= '<li class="ui-state-green attribute_end_line" id="wps-attribute-end-line">' .__( 'End line', 'wpshop' ). '</li>'; |
|
| 805 | + if (!empty($end_line_display) && !empty($end_line_display[$attributeSetIDGroup]) && in_array('attribute_' . $attributInGroup->id, $end_line_display[$attributeSetIDGroup])) { |
|
| 806 | + $key = array_search('attribute_' . $attributInGroup->id, $end_line_display[$attributeSetIDGroup]); |
|
| 807 | + if (!empty($end_line_display[$attributeSetIDGroup][$key + 1]) && $end_line_display[$attributeSetIDGroup][$key + 1] == 'wps-attribute-end-line-' . $end_line_id) { |
|
| 808 | + $attributeSetDetailsManagement .= '<li class="ui-state-green attribute_end_line" id="wps-attribute-end-line">' . __('End line', 'wpshop') . '</li>'; |
|
| 809 | 809 | $end_line_id++; |
| 810 | 810 | } |
| 811 | 811 | } |
@@ -817,15 +817,15 @@ discard block |
||
| 817 | 817 | </ul>'; |
| 818 | 818 | } |
| 819 | 819 | |
| 820 | - $attributeSetDetailsManagement .= $edition_area.' |
|
| 820 | + $attributeSetDetailsManagement .= $edition_area . ' |
|
| 821 | 821 | </td> |
| 822 | 822 | </tr> |
| 823 | 823 | </table> |
| 824 | 824 | |
| 825 | 825 | <div class="wpshop_admin_toolbox wpshop_attr_set_section_tool_box" >' . $edit_button; |
| 826 | - if ( current_user_can('wpshop_delete_attribute_group') && !$no_delete_button ) { |
|
| 826 | + if (current_user_can('wpshop_delete_attribute_group') && !$no_delete_button) { |
|
| 827 | 827 | $attributeSetDetailsManagement .= ' |
| 828 | - <a class="wpshop_attr_tool_box_button wpshop_attr_tool_box_delete wpshop_attr_tool_box_delete_attribute_set_section" id="wpshop_set_section_delete_'.$attributeSetDetailsGroup['id'].'" title="'.__('Delete this section', 'wpshop').'"></a>'; |
|
| 828 | + <a class="wpshop_attr_tool_box_button wpshop_attr_tool_box_delete wpshop_attr_tool_box_delete_attribute_set_section" id="wpshop_set_section_delete_'.$attributeSetDetailsGroup['id'] . '" title="' . __('Delete this section', 'wpshop') . '"></a>'; |
|
| 829 | 829 | } |
| 830 | 830 | $attributeSetDetailsManagement .= ' |
| 831 | 831 | </div> |
@@ -845,9 +845,9 @@ discard block |
||
| 845 | 845 | |
| 846 | 846 | /* Get the not affected attribute list */ |
| 847 | 847 | $notAffectedAttributeList = self::get_not_affected_attribute($attributeSetId, $attributeSetDetailsGroup['entity_id']); |
| 848 | - if(count($notAffectedAttributeList) > 0){ |
|
| 849 | - foreach($notAffectedAttributeList as $notAffectedAttribute){ |
|
| 850 | - if( (is_null($validAttributeList) || !in_array($notAffectedAttribute->id, $validAttributeList)) && ( $notAffectedAttribute->code != 'product_attribute_set_id' ) && ($attributeSetDetailsGroup['entity_id'] == $notAffectedAttribute->entity_id) ){ |
|
| 848 | + if (count($notAffectedAttributeList) > 0) { |
|
| 849 | + foreach ($notAffectedAttributeList as $notAffectedAttribute) { |
|
| 850 | + if ((is_null($validAttributeList) || !in_array($notAffectedAttribute->id, $validAttributeList)) && ($notAffectedAttribute->code != 'product_attribute_set_id') && ($attributeSetDetailsGroup['entity_id'] == $notAffectedAttribute->entity_id)) { |
|
| 851 | 851 | |
| 852 | 852 | $attributeSetDetailsManagement .= ' |
| 853 | 853 | <li class="ui-state-default attribute" id="attribute_' . $notAffectedAttribute->id . '" >' . __($notAffectedAttribute->frontend_label, 'wpshop') . '</li>'; |
@@ -861,20 +861,20 @@ discard block |
||
| 861 | 861 | </fieldset> |
| 862 | 862 | </div>'; |
| 863 | 863 | |
| 864 | - if ( !empty($attributeSetId) ) { |
|
| 865 | - $query = $wpdb->prepare( 'SELECT entity_id FROM '.WPSHOP_DBT_ATTRIBUTE_SET. ' WHERE id = %d', $attributeSetId ); |
|
| 866 | - $entity_id = $wpdb->get_var( $query ); |
|
| 867 | - if ( !empty($entity_id) ) { |
|
| 868 | - $entity_post = get_post( $entity_id ); |
|
| 869 | - if( !empty( $entity_post) && !empty($entity_post->post_type) && $entity_post->post_type == WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES && !empty($entity_post->post_name) && $entity_post->post_name == WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS ) { |
|
| 870 | - $attributeSetDetailsManagement .= '<ul class="wps_attribute_set_end_line"><li class="ui-state-green attribute_end_line" id="wps-attribute-end-line">' .__( 'End line', 'wpshop' ). '</li></ul>'; |
|
| 864 | + if (!empty($attributeSetId)) { |
|
| 865 | + $query = $wpdb->prepare('SELECT entity_id FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE id = %d', $attributeSetId); |
|
| 866 | + $entity_id = $wpdb->get_var($query); |
|
| 867 | + if (!empty($entity_id)) { |
|
| 868 | + $entity_post = get_post($entity_id); |
|
| 869 | + if (!empty($entity_post) && !empty($entity_post->post_type) && $entity_post->post_type == WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES && !empty($entity_post->post_name) && $entity_post->post_name == WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS) { |
|
| 870 | + $attributeSetDetailsManagement .= '<ul class="wps_attribute_set_end_line"><li class="ui-state-green attribute_end_line" id="wps-attribute-end-line">' . __('End line', 'wpshop') . '</li></ul>'; |
|
| 871 | 871 | } |
| 872 | 872 | } |
| 873 | 873 | } |
| 874 | - if(current_user_can('wpshop_delete_attribute_group')){ |
|
| 874 | + if (current_user_can('wpshop_delete_attribute_group')) { |
|
| 875 | 875 | $user_more_script .= ' |
| 876 | 876 | jQuery(".wpshop_attr_tool_box_delete").click(function(){ |
| 877 | - if(confirm(wpshopConvertAccentTojs("'.__('Are you sure you want to delete this atribute set section?', 'wpshop').'"))){ |
|
| 877 | + if(confirm(wpshopConvertAccentTojs("'.__('Are you sure you want to delete this atribute set section?', 'wpshop') . '"))){ |
|
| 878 | 878 | jQuery("#ajax-response").load(ajaxurl,{ |
| 879 | 879 | "action": "wps_attribute_set_section_delete", |
| 880 | 880 | "_wpnonce": "' . wp_create_nonce("deleteAttributeSetSection") . '", |
@@ -886,7 +886,7 @@ discard block |
||
| 886 | 886 | $attributeSetDetailsManagement .= ' |
| 887 | 887 | <script type="text/javascript" > |
| 888 | 888 | wpshop(document).ready(function(){ |
| 889 | - make_list_sortable("' . WPSHOP_DBT_ATTRIBUTE_SET . '");'.$user_more_script.' |
|
| 889 | + make_list_sortable("' . WPSHOP_DBT_ATTRIBUTE_SET . '");' . $user_more_script . ' |
|
| 890 | 890 | }); |
| 891 | 891 | </script> |
| 892 | 892 | <div class="wpshop_cls"></div> |
@@ -953,7 +953,7 @@ discard block |
||
| 953 | 953 | * |
| 954 | 954 | * @return array $attributeSetDetailsGroups The List of attribute and attribute groups for the given attribute set |
| 955 | 955 | */ |
| 956 | - public static function getAttributeSetDetails($attributeSetId, $attributeSetStatus = "'valid', 'moderated'"){ |
|
| 956 | + public static function getAttributeSetDetails($attributeSetId, $attributeSetStatus = "'valid', 'moderated'") { |
|
| 957 | 957 | global $wpdb, $validAttributeList; |
| 958 | 958 | $attributeSetDetailsGroups = ''; |
| 959 | 959 | |
@@ -973,7 +973,7 @@ discard block |
||
| 973 | 973 | $attributeSetId); |
| 974 | 974 | $attributeSetDetails = $wpdb->get_results($query); |
| 975 | 975 | |
| 976 | - foreach ( $attributeSetDetails as $attributeGroup ) { |
|
| 976 | + foreach ($attributeSetDetails as $attributeGroup) { |
|
| 977 | 977 | $attributeSetDetailsGroups[$attributeGroup->attr_group_id]['attribute_set_id'] = $attributeGroup->attribute_set_id; |
| 978 | 978 | $attributeSetDetailsGroups[$attributeGroup->attr_group_id]['id'] = $attributeGroup->attribute_detail_id; |
| 979 | 979 | $attributeSetDetailsGroups[$attributeGroup->attr_group_id]['code'] = $attributeGroup->attr_group_code; |
@@ -984,17 +984,17 @@ discard block |
||
| 984 | 984 | $attributeSetDetailsGroups[$attributeGroup->attr_group_id]['display_on_frontend'] = $attributeGroup->display_on_frontend; |
| 985 | 985 | $attributeSetDetailsGroups[$attributeGroup->attr_group_id]['entity_id'] = $attributeGroup->entity_id; |
| 986 | 986 | |
| 987 | - if ( empty($done_position) || empty($done_position[$attributeGroup->attr_group_id]) ) { |
|
| 987 | + if (empty($done_position) || empty($done_position[$attributeGroup->attr_group_id])) { |
|
| 988 | 988 | $done_position[$attributeGroup->attr_group_id] = array(); |
| 989 | 989 | } |
| 990 | 990 | $position_to_take = $attributeGroup->attr_position_in_group; |
| 991 | - if ( in_array($position_to_take, $done_position[$attributeGroup->attr_group_id]) ) { |
|
| 991 | + if (in_array($position_to_take, $done_position[$attributeGroup->attr_group_id])) { |
|
| 992 | 992 | $position_to_take = max($done_position[$attributeGroup->attr_group_id]) + 1; |
| 993 | 993 | } |
| 994 | 994 | $done_position[$attributeGroup->attr_group_id][] = $position_to_take; |
| 995 | 995 | $attributeSetDetailsGroups[$attributeGroup->attr_group_id]['attribut'][$position_to_take] = $attributeGroup; |
| 996 | 996 | $attributeSetDetailsGroups[$attributeGroup->attr_group_id]['is_used_in_quick_add_form'] = $attributeGroup->is_used_in_quick_add_form; |
| 997 | - if ( in_array($attributeGroup->code, unserialize(WPSHOP_ATTRIBUTE_PRICES)) ) { |
|
| 997 | + if (in_array($attributeGroup->code, unserialize(WPSHOP_ATTRIBUTE_PRICES))) { |
|
| 998 | 998 | $attributeSetDetailsGroups[$attributeGroup->attr_group_id]['prices'][$attributeGroup->code] = $attributeGroup; |
| 999 | 999 | } |
| 1000 | 1000 | $validAttributeList[] = $attributeGroup->id; |
@@ -1010,7 +1010,7 @@ discard block |
||
| 1010 | 1010 | * |
| 1011 | 1011 | * @return array $attributeSetDetails The List of attribute not affected |
| 1012 | 1012 | */ |
| 1013 | - public static function get_not_affected_attribute($attributeSetId, $entity_set_id){ |
|
| 1013 | + public static function get_not_affected_attribute($attributeSetId, $entity_set_id) { |
|
| 1014 | 1014 | global $wpdb; |
| 1015 | 1015 | |
| 1016 | 1016 | $query = $wpdb->prepare( |
@@ -1050,7 +1050,7 @@ discard block |
||
| 1050 | 1050 | * |
| 1051 | 1051 | * @return object $entitySets The entity sets list for the given entity |
| 1052 | 1052 | */ |
| 1053 | - public static function get_attribute_set_list_for_entity($entityId){ |
|
| 1053 | + public static function get_attribute_set_list_for_entity($entityId) { |
|
| 1054 | 1054 | global $wpdb; |
| 1055 | 1055 | $entitySetList = ''; |
| 1056 | 1056 | |
@@ -1074,39 +1074,39 @@ discard block |
||
| 1074 | 1074 | global $wpdb; |
| 1075 | 1075 | |
| 1076 | 1076 | $query = ' |
| 1077 | - SELECT '.WPSHOP_DBT_ATTRIBUTE.'.frontend_label, '.WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL.'.value AS value_decimal, '.WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME.'.value AS value_datetime, '.WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER.'.value AS value_integer, |
|
| 1078 | - '.WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT.'.value AS value_text, '.WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR.'.value AS value_varchar, '.WPSHOP_DBT_ATTRIBUTE_UNIT.'.unit AS unit, '.WPSHOP_DBT_ATTRIBUTE.'.frontend_verification |
|
| 1079 | - FROM '.WPSHOP_DBT_ATTRIBUTE_DETAILS.' |
|
| 1080 | - LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE.' ON '.WPSHOP_DBT_ATTRIBUTE_DETAILS.'.attribute_id='.WPSHOP_DBT_ATTRIBUTE.'.id |
|
| 1081 | - LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL.' ON '.WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL.'.attribute_id='.WPSHOP_DBT_ATTRIBUTE.'.id |
|
| 1082 | - LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME.' ON '.WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME.'.attribute_id='.WPSHOP_DBT_ATTRIBUTE.'.id |
|
| 1083 | - LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER.' ON '.WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER.'.attribute_id='.WPSHOP_DBT_ATTRIBUTE.'.id |
|
| 1084 | - LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT.' ON '.WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT.'.attribute_id='.WPSHOP_DBT_ATTRIBUTE.'.id |
|
| 1085 | - LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR.' ON '.WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR.'.attribute_id='.WPSHOP_DBT_ATTRIBUTE.'.id |
|
| 1086 | - LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE_UNIT.' ON ( |
|
| 1087 | - '.WPSHOP_DBT_ATTRIBUTE_UNIT.'.id='.WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL.'.unit_id |
|
| 1088 | - OR '.WPSHOP_DBT_ATTRIBUTE_UNIT.'.id='.WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME.'.unit_id |
|
| 1089 | - OR '.WPSHOP_DBT_ATTRIBUTE_UNIT.'.id='.WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER.'.unit_id |
|
| 1090 | - OR '.WPSHOP_DBT_ATTRIBUTE_UNIT.'.id='.WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT.'.unit_id |
|
| 1091 | - OR '.WPSHOP_DBT_ATTRIBUTE_UNIT.'.id='.WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR.'.unit_id |
|
| 1077 | + SELECT '.WPSHOP_DBT_ATTRIBUTE . '.frontend_label, ' . WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL . '.value AS value_decimal, ' . WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME . '.value AS value_datetime, ' . WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER . '.value AS value_integer, |
|
| 1078 | + '.WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT . '.value AS value_text, ' . WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR . '.value AS value_varchar, ' . WPSHOP_DBT_ATTRIBUTE_UNIT . '.unit AS unit, ' . WPSHOP_DBT_ATTRIBUTE . '.frontend_verification |
|
| 1079 | + FROM '.WPSHOP_DBT_ATTRIBUTE_DETAILS . ' |
|
| 1080 | + LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE . ' ON ' . WPSHOP_DBT_ATTRIBUTE_DETAILS . '.attribute_id=' . WPSHOP_DBT_ATTRIBUTE . '.id |
|
| 1081 | + LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL . ' ON ' . WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL . '.attribute_id=' . WPSHOP_DBT_ATTRIBUTE . '.id |
|
| 1082 | + LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME . ' ON ' . WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME . '.attribute_id=' . WPSHOP_DBT_ATTRIBUTE . '.id |
|
| 1083 | + LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER . ' ON ' . WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER . '.attribute_id=' . WPSHOP_DBT_ATTRIBUTE . '.id |
|
| 1084 | + LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT . ' ON ' . WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT . '.attribute_id=' . WPSHOP_DBT_ATTRIBUTE . '.id |
|
| 1085 | + LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR . ' ON ' . WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR . '.attribute_id=' . WPSHOP_DBT_ATTRIBUTE . '.id |
|
| 1086 | + LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE_UNIT . ' ON ( |
|
| 1087 | + '.WPSHOP_DBT_ATTRIBUTE_UNIT . '.id=' . WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL . '.unit_id |
|
| 1088 | + OR '.WPSHOP_DBT_ATTRIBUTE_UNIT . '.id=' . WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME . '.unit_id |
|
| 1089 | + OR '.WPSHOP_DBT_ATTRIBUTE_UNIT . '.id=' . WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER . '.unit_id |
|
| 1090 | + OR '.WPSHOP_DBT_ATTRIBUTE_UNIT . '.id=' . WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT . '.unit_id |
|
| 1091 | + OR '.WPSHOP_DBT_ATTRIBUTE_UNIT . '.id=' . WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR . '.unit_id |
|
| 1092 | 1092 | ) |
| 1093 | 1093 | WHERE |
| 1094 | - '.WPSHOP_DBT_ATTRIBUTE_DETAILS.'.status="valid" |
|
| 1095 | - AND '.WPSHOP_DBT_ATTRIBUTE.'.status="valid" |
|
| 1096 | - AND '.WPSHOP_DBT_ATTRIBUTE_DETAILS.'.attribute_group_id IN ('.$atts['sid'].') |
|
| 1094 | + '.WPSHOP_DBT_ATTRIBUTE_DETAILS . '.status="valid" |
|
| 1095 | + AND '.WPSHOP_DBT_ATTRIBUTE . '.status="valid" |
|
| 1096 | + AND '.WPSHOP_DBT_ATTRIBUTE_DETAILS . '.attribute_group_id IN (' . $atts['sid'] . ') |
|
| 1097 | 1097 | AND ( |
| 1098 | - '.WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL.'.entity_id='.$atts['pid'].' |
|
| 1099 | - OR '.WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME.'.entity_id='.$atts['pid'].' |
|
| 1100 | - OR '.WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER.'.entity_id='.$atts['pid'].' |
|
| 1101 | - OR '.WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT.'.entity_id='.$atts['pid'].' |
|
| 1102 | - OR '.WPSHOP_DBT_ATTRIBUTE.'_value_varchar.entity_id='.$atts['pid'].' |
|
| 1098 | + '.WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL . '.entity_id=' . $atts['pid'] . ' |
|
| 1099 | + OR '.WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME . '.entity_id=' . $atts['pid'] . ' |
|
| 1100 | + OR '.WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER . '.entity_id=' . $atts['pid'] . ' |
|
| 1101 | + OR '.WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT . '.entity_id=' . $atts['pid'] . ' |
|
| 1102 | + OR '.WPSHOP_DBT_ATTRIBUTE . '_value_varchar.entity_id=' . $atts['pid'] . ' |
|
| 1103 | 1103 | ) |
| 1104 | 1104 | '; |
| 1105 | 1105 | $data = $wpdb->get_results($query); |
| 1106 | - foreach($data as $d) { |
|
| 1106 | + foreach ($data as $d) { |
|
| 1107 | 1107 | $value_style_start = $value_style_end = ''; |
| 1108 | - if ( !empty($d->frontend_verification) ) { |
|
| 1109 | - switch ( $d->frontend_verification ) { |
|
| 1108 | + if (!empty($d->frontend_verification)) { |
|
| 1109 | + switch ($d->frontend_verification) { |
|
| 1110 | 1110 | case 'phone': |
| 1111 | 1111 | $value_style_start = '<a href="tel:' . $d->value_decimal . $d->value_datetime . $d->value_integer . $d->value_text . $d->value_varchar . '" >'; |
| 1112 | 1112 | $value_style_end = '</a>'; |
@@ -1117,7 +1117,7 @@ discard block |
||
| 1117 | 1117 | break; |
| 1118 | 1118 | } |
| 1119 | 1119 | } |
| 1120 | - echo '<strong>'.__($d->frontend_label, 'wpshop').'</strong> : ' . $value_style_start . $d->value_decimal . $d->value_datetime . $d->value_integer . $d->value_text . $d->value_varchar . $value_style_end . ( !empty($d->unit) ? ' ('.$d->unit.')' : '' ) . '<br />'; |
|
| 1120 | + echo '<strong>' . __($d->frontend_label, 'wpshop') . '</strong> : ' . $value_style_start . $d->value_decimal . $d->value_datetime . $d->value_integer . $d->value_text . $d->value_varchar . $value_style_end . (!empty($d->unit) ? ' (' . $d->unit . ')' : '') . '<br />'; |
|
| 1121 | 1121 | } |
| 1122 | 1122 | } |
| 1123 | 1123 | |
@@ -1132,31 +1132,31 @@ discard block |
||
| 1132 | 1132 | * |
| 1133 | 1133 | * @return string Le code html permettant d'afficher la liste des groupes et/ou sous-groupes d'attributs |
| 1134 | 1134 | */ |
| 1135 | - public static function get_attribute_set_complete_list($entity_id, $table, $page_code, $complete_tree = true){ |
|
| 1135 | + public static function get_attribute_set_complete_list($entity_id, $table, $page_code, $complete_tree = true) { |
|
| 1136 | 1136 | $the_input = __('There is no attribute set for this entity', 'wpshop'); |
| 1137 | 1137 | |
| 1138 | 1138 | $attr_set_list = wpshop_attributes_set::getElement($entity_id, "'valid'", 'entity_id', 'all'); |
| 1139 | - if ( !empty($attr_set_list) ) { |
|
| 1139 | + if (!empty($attr_set_list)) { |
|
| 1140 | 1140 | $the_input = '<select name="' . $table . '[set_section]" class="wpshop_' . $page_code . '_set_section" >'; |
| 1141 | 1141 | if (!$complete_tree) { |
| 1142 | - $the_input .= '<option value="0">'.__('None', 'wpshop').'</option>'; |
|
| 1142 | + $the_input .= '<option value="0">' . __('None', 'wpshop') . '</option>'; |
|
| 1143 | 1143 | } |
| 1144 | 1144 | |
| 1145 | - foreach ( $attr_set_list as $attr_set_index => $attr_set ) { |
|
| 1146 | - if ( !empty($attr_set->id) ) { |
|
| 1145 | + foreach ($attr_set_list as $attr_set_index => $attr_set) { |
|
| 1146 | + if (!empty($attr_set->id)) { |
|
| 1147 | 1147 | $attribute_set_details = wpshop_attributes_set::getAttributeSetDetails($attr_set->id, "'valid'"); |
| 1148 | - if ( !empty($attribute_set_details) ) { |
|
| 1148 | + if (!empty($attribute_set_details)) { |
|
| 1149 | 1149 | |
| 1150 | 1150 | if ($complete_tree) { |
| 1151 | - $the_input .= '<optgroup label="'.__($attr_set->name, 'wpshop').'" >'; |
|
| 1152 | - foreach ( $attribute_set_details as $set_details ) { |
|
| 1153 | - $selected = ( ( $attr_set->default_set == 'yes' ) && ( $set_details['is_default_group'] == 'yes' ) ? ' selected="selected"' : '' ); |
|
| 1154 | - $the_input .= '<option'.$selected.' value="'.$attr_set->id.'_'.$set_details['id'].'">'.__($set_details['name'],'wpshop').'</option>'; |
|
| 1151 | + $the_input .= '<optgroup label="' . __($attr_set->name, 'wpshop') . '" >'; |
|
| 1152 | + foreach ($attribute_set_details as $set_details) { |
|
| 1153 | + $selected = (($attr_set->default_set == 'yes') && ($set_details['is_default_group'] == 'yes') ? ' selected="selected"' : ''); |
|
| 1154 | + $the_input .= '<option' . $selected . ' value="' . $attr_set->id . '_' . $set_details['id'] . '">' . __($set_details['name'], 'wpshop') . '</option>'; |
|
| 1155 | 1155 | } |
| 1156 | 1156 | $the_input .= '</optgroup>'; |
| 1157 | 1157 | } |
| 1158 | 1158 | else { |
| 1159 | - $the_input .= '<option value="'.$attr_set->id.'">'.__($attr_set->name, 'wpshop').'</option>'; |
|
| 1159 | + $the_input .= '<option value="' . $attr_set->id . '">' . __($attr_set->name, 'wpshop') . '</option>'; |
|
| 1160 | 1160 | } |
| 1161 | 1161 | } |
| 1162 | 1162 | } |
@@ -43,42 +43,42 @@ discard block |
||
| 43 | 43 | public $pageMessage = ''; |
| 44 | 44 | |
| 45 | 45 | /** |
| 46 | - * Get the url listing slug of the current class |
|
| 47 | - * |
|
| 48 | - * @return string The table of the class |
|
| 49 | - */ |
|
| 46 | + * Get the url listing slug of the current class |
|
| 47 | + * |
|
| 48 | + * @return string The table of the class |
|
| 49 | + */ |
|
| 50 | 50 | function setMessage($message){ |
| 51 | 51 | $this->pageMessage = $message; |
| 52 | 52 | } |
| 53 | 53 | /** |
| 54 | - * Get the url listing slug of the current class |
|
| 55 | - * |
|
| 56 | - * @return string The table of the class |
|
| 57 | - */ |
|
| 54 | + * Get the url listing slug of the current class |
|
| 55 | + * |
|
| 56 | + * @return string The table of the class |
|
| 57 | + */ |
|
| 58 | 58 | function getListingSlug(){ |
| 59 | 59 | return self::urlSlugListing; |
| 60 | 60 | } |
| 61 | 61 | /** |
| 62 | - * Get the url edition slug of the current class |
|
| 63 | - * |
|
| 64 | - * @return string The table of the class |
|
| 65 | - */ |
|
| 62 | + * Get the url edition slug of the current class |
|
| 63 | + * |
|
| 64 | + * @return string The table of the class |
|
| 65 | + */ |
|
| 66 | 66 | public static function getEditionSlug(){ |
| 67 | 67 | return self::urlSlugEdition; |
| 68 | 68 | } |
| 69 | 69 | /** |
| 70 | - * Get the database table of the current class |
|
| 71 | - * |
|
| 72 | - * @return string The table of the class |
|
| 73 | - */ |
|
| 70 | + * Get the database table of the current class |
|
| 71 | + * |
|
| 72 | + * @return string The table of the class |
|
| 73 | + */ |
|
| 74 | 74 | public static function getDbTable(){ |
| 75 | 75 | return self::dbTable; |
| 76 | 76 | } |
| 77 | 77 | /** |
| 78 | - * Define the title of the page |
|
| 79 | - * |
|
| 80 | - * @return string $title The title of the page looking at the environnement |
|
| 81 | - */ |
|
| 78 | + * Define the title of the page |
|
| 79 | + * |
|
| 80 | + * @return string $title The title of the page looking at the environnement |
|
| 81 | + */ |
|
| 82 | 82 | function pageTitle(){ |
| 83 | 83 | $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : ''; |
| 84 | 84 | $objectInEdition = isset($_REQUEST['id']) ? sanitize_key($_REQUEST['id']) : ''; |
@@ -96,8 +96,8 @@ discard block |
||
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
| 99 | - * Define the different message and action after an action is send through the element interface |
|
| 100 | - */ |
|
| 99 | + * Define the different message and action after an action is send through the element interface |
|
| 100 | + */ |
|
| 101 | 101 | function elementAction(){ |
| 102 | 102 | global $wpdb, $initialEavData; |
| 103 | 103 | $pageMessage = $actionResult = ''; |
@@ -365,14 +365,14 @@ discard block |
||
| 365 | 365 | self::setMessage($pageMessage); |
| 366 | 366 | } |
| 367 | 367 | /** |
| 368 | - * Return the list page content, containing the table that present the item list |
|
| 369 | - * |
|
| 370 | - * @return string $listItemOutput The html code that output the item list |
|
| 371 | - */ |
|
| 368 | + * Return the list page content, containing the table that present the item list |
|
| 369 | + * |
|
| 370 | + * @return string $listItemOutput The html code that output the item list |
|
| 371 | + */ |
|
| 372 | 372 | function elementList() { |
| 373 | - //Create an instance of our package class... |
|
| 374 | - $wpshop_list_table = new wpshop_attributes_set_custom_List_table(); |
|
| 375 | - //Fetch, prepare, sort, and filter our data... |
|
| 373 | + //Create an instance of our package class... |
|
| 374 | + $wpshop_list_table = new wpshop_attributes_set_custom_List_table(); |
|
| 375 | + //Fetch, prepare, sort, and filter our data... |
|
| 376 | 376 | $status="'valid', 'moderated'"; |
| 377 | 377 | $attribute_set_list = array(); |
| 378 | 378 | $attribute_group_status = !empty( $_REQUEST['attribute_groups_status'] ) ? sanitize_text_field( $_REQUEST['attribute_groups_status'] ) : ''; |
@@ -430,10 +430,10 @@ discard block |
||
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | /** |
| 433 | - * Return the page content to add a new item |
|
| 434 | - * |
|
| 435 | - * @return string The html code that output the interface for adding a nem item |
|
| 436 | - */ |
|
| 433 | + * Return the page content to add a new item |
|
| 434 | + * |
|
| 435 | + * @return string The html code that output the interface for adding a nem item |
|
| 436 | + */ |
|
| 437 | 437 | function elementEdition($itemToEdit = '') { |
| 438 | 438 | global $attribute_hidden_field; |
| 439 | 439 | |
@@ -581,10 +581,10 @@ discard block |
||
| 581 | 581 | return $the_form; |
| 582 | 582 | } |
| 583 | 583 | /** |
| 584 | - * Return the different button to save the item currently being added or edited |
|
| 585 | - * |
|
| 586 | - * @return string $currentPageButton The html output code with the different button to add to the interface |
|
| 587 | - */ |
|
| 584 | + * Return the different button to save the item currently being added or edited |
|
| 585 | + * |
|
| 586 | + * @return string $currentPageButton The html output code with the different button to add to the interface |
|
| 587 | + */ |
|
| 588 | 588 | function getPageFormButton($element_id = 0){ |
| 589 | 589 | $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : 'add'; |
| 590 | 590 | $currentPageButton = ''; |
@@ -593,13 +593,13 @@ discard block |
||
| 593 | 593 | } |
| 594 | 594 | |
| 595 | 595 | /** |
| 596 | - * Get the existing element list into database |
|
| 597 | - * |
|
| 598 | - * @param integer $elementId optionnal The element identifier we want to get. If not specify the entire list will be returned |
|
| 599 | - * @param string $elementStatus optionnal The status of element to get into database. Default is set to valid element |
|
| 600 | - * |
|
| 601 | - * @return object $elements A wordpress database object containing the element list |
|
| 602 | - */ |
|
| 596 | + * Get the existing element list into database |
|
| 597 | + * |
|
| 598 | + * @param integer $elementId optionnal The element identifier we want to get. If not specify the entire list will be returned |
|
| 599 | + * @param string $elementStatus optionnal The status of element to get into database. Default is set to valid element |
|
| 600 | + * |
|
| 601 | + * @return object $elements A wordpress database object containing the element list |
|
| 602 | + */ |
|
| 603 | 603 | public static function getElement($elementId = '', $elementStatus = "'valid', 'moderated'", $whatToSearch = 'id', $resultList = '', $entity_id = ''){ |
| 604 | 604 | global $wpdb; |
| 605 | 605 | $elements = array(); |
@@ -670,12 +670,12 @@ discard block |
||
| 670 | 670 | } |
| 671 | 671 | |
| 672 | 672 | /** |
| 673 | - * Display inteface allowing to manage the attribute set and group details |
|
| 674 | - * |
|
| 675 | - * @param object $atributeSetId The element's identifier we have to manage the details for |
|
| 676 | - * |
|
| 677 | - * @return string $attributeSetDetailsManagement The html output of management interface |
|
| 678 | - */ |
|
| 673 | + * Display inteface allowing to manage the attribute set and group details |
|
| 674 | + * |
|
| 675 | + * @param object $atributeSetId The element's identifier we have to manage the details for |
|
| 676 | + * |
|
| 677 | + * @return string $attributeSetDetailsManagement The html output of management interface |
|
| 678 | + */ |
|
| 679 | 679 | public static function attributeSetDetailsManagement($attributeSetId = ''){ |
| 680 | 680 | global $validAttributeList; global $wpdb; |
| 681 | 681 | $user_more_script = $add_button = ''; |
@@ -946,13 +946,13 @@ discard block |
||
| 946 | 946 | } |
| 947 | 947 | |
| 948 | 948 | /** |
| 949 | - * Get the complete details about attributes sets |
|
| 950 | - * |
|
| 951 | - * @param integer $attributeSetId The attribute set identifier we want to get the details for |
|
| 952 | - * @param string $attributeSetStatus optionnal The attribute set status. Allows to define if we want all attribute sets or a deleted or valid and so on |
|
| 953 | - * |
|
| 954 | - * @return array $attributeSetDetailsGroups The List of attribute and attribute groups for the given attribute set |
|
| 955 | - */ |
|
| 949 | + * Get the complete details about attributes sets |
|
| 950 | + * |
|
| 951 | + * @param integer $attributeSetId The attribute set identifier we want to get the details for |
|
| 952 | + * @param string $attributeSetStatus optionnal The attribute set status. Allows to define if we want all attribute sets or a deleted or valid and so on |
|
| 953 | + * |
|
| 954 | + * @return array $attributeSetDetailsGroups The List of attribute and attribute groups for the given attribute set |
|
| 955 | + */ |
|
| 956 | 956 | public static function getAttributeSetDetails($attributeSetId, $attributeSetStatus = "'valid', 'moderated'"){ |
| 957 | 957 | global $wpdb, $validAttributeList; |
| 958 | 958 | $attributeSetDetailsGroups = ''; |
@@ -1004,12 +1004,12 @@ discard block |
||
| 1004 | 1004 | } |
| 1005 | 1005 | |
| 1006 | 1006 | /** |
| 1007 | - * Get the attribute list of attribute not associated to he set we are editing |
|
| 1008 | - * |
|
| 1009 | - * @param integer $attributeSetId The attribute set identifier we want to get the details for |
|
| 1010 | - * |
|
| 1011 | - * @return array $attributeSetDetails The List of attribute not affected |
|
| 1012 | - */ |
|
| 1007 | + * Get the attribute list of attribute not associated to he set we are editing |
|
| 1008 | + * |
|
| 1009 | + * @param integer $attributeSetId The attribute set identifier we want to get the details for |
|
| 1010 | + * |
|
| 1011 | + * @return array $attributeSetDetails The List of attribute not affected |
|
| 1012 | + */ |
|
| 1013 | 1013 | public static function get_not_affected_attribute($attributeSetId, $entity_set_id){ |
| 1014 | 1014 | global $wpdb; |
| 1015 | 1015 | |
@@ -1044,12 +1044,12 @@ discard block |
||
| 1044 | 1044 | } |
| 1045 | 1045 | |
| 1046 | 1046 | /** |
| 1047 | - * Get the existing attribute set for an entity |
|
| 1048 | - * |
|
| 1049 | - * @param integer $entityId The entity identifier we want to get the entity set list for |
|
| 1050 | - * |
|
| 1051 | - * @return object $entitySets The entity sets list for the given entity |
|
| 1052 | - */ |
|
| 1047 | + * Get the existing attribute set for an entity |
|
| 1048 | + * |
|
| 1049 | + * @param integer $entityId The entity identifier we want to get the entity set list for |
|
| 1050 | + * |
|
| 1051 | + * @return object $entitySets The entity sets list for the given entity |
|
| 1052 | + */ |
|
| 1053 | 1053 | public static function get_attribute_set_list_for_entity($entityId){ |
| 1054 | 1054 | global $wpdb; |
| 1055 | 1055 | $entitySetList = ''; |
@@ -1066,10 +1066,10 @@ discard block |
||
| 1066 | 1066 | } |
| 1067 | 1067 | |
| 1068 | 1068 | /** |
| 1069 | - * Traduit le shortcode et affiche un groupe d'attributs |
|
| 1070 | - * @param array $atts : tableau de param�tre du shortcode |
|
| 1071 | - * @return mixed |
|
| 1072 | - **/ |
|
| 1069 | + * Traduit le shortcode et affiche un groupe d'attributs |
|
| 1070 | + * @param array $atts : tableau de param�tre du shortcode |
|
| 1071 | + * @return mixed |
|
| 1072 | + **/ |
|
| 1073 | 1073 | public static function wpshop_att_group_func($atts) { |
| 1074 | 1074 | global $wpdb; |
| 1075 | 1075 | |
@@ -68,6 +68,7 @@ discard block |
||
| 68 | 68 | /** |
| 69 | 69 | * Get the url listing slug of the current class |
| 70 | 70 | * |
| 71 | + * @param string $message |
|
| 71 | 72 | * @return string The table of the class |
| 72 | 73 | */ |
| 73 | 74 | function setMessage($message) |
@@ -519,7 +520,7 @@ discard block |
||
| 519 | 520 | * |
| 520 | 521 | * @param integer $element_id optionnal The attribute identifier we want to get. If not specify the entire list will be returned |
| 521 | 522 | * @param string $element_status optionnal The status of element to get into database. Default is set to valid element |
| 522 | - * @param mixed $field_to_search optionnal The field we want to check the row identifier into. Default is to set id |
|
| 523 | + * @param string $field_to_search optionnal The field we want to check the row identifier into. Default is to set id |
|
| 523 | 524 | * |
| 524 | 525 | * @return object $element_list A wordpress database object containing the attribute list |
| 525 | 526 | */ |
@@ -24,45 +24,45 @@ discard block |
||
| 24 | 24 | class wpshop_attributes_unit |
| 25 | 25 | { |
| 26 | 26 | /** |
| 27 | - * Define the database table used in the current class |
|
| 28 | - */ |
|
| 27 | + * Define the database table used in the current class |
|
| 28 | + */ |
|
| 29 | 29 | const dbTable = WPSHOP_DBT_ATTRIBUTE_UNIT; |
| 30 | 30 | /** |
| 31 | - * Define the url listing slug used in the current class |
|
| 32 | - */ |
|
| 31 | + * Define the url listing slug used in the current class |
|
| 32 | + */ |
|
| 33 | 33 | const urlSlugListing = WPSHOP_URL_SLUG_ATTRIBUTE_LISTING; |
| 34 | 34 | /** |
| 35 | - * Define the url edition slug used in the current class |
|
| 36 | - */ |
|
| 35 | + * Define the url edition slug used in the current class |
|
| 36 | + */ |
|
| 37 | 37 | const urlSlugEdition = WPSHOP_URL_SLUG_ATTRIBUTE_LISTING; |
| 38 | 38 | /** |
| 39 | - * Define the current entity code |
|
| 40 | - */ |
|
| 39 | + * Define the current entity code |
|
| 40 | + */ |
|
| 41 | 41 | const currentPageCode = 'attributes_unit'; |
| 42 | 42 | /** |
| 43 | - * Define the page title |
|
| 44 | - */ |
|
| 43 | + * Define the page title |
|
| 44 | + */ |
|
| 45 | 45 | const pageContentTitle = 'Attributes unit'; |
| 46 | 46 | /** |
| 47 | - * Define the page title when adding an attribute |
|
| 48 | - */ |
|
| 47 | + * Define the page title when adding an attribute |
|
| 48 | + */ |
|
| 49 | 49 | const pageAddingTitle = 'Add an unit'; |
| 50 | 50 | /** |
| 51 | - * Define the page title when editing an attribute |
|
| 52 | - */ |
|
| 51 | + * Define the page title when editing an attribute |
|
| 52 | + */ |
|
| 53 | 53 | const pageEditingTitle = 'Unit "%s" edit'; |
| 54 | 54 | /** |
| 55 | - * Define the page title when editing an attribute |
|
| 56 | - */ |
|
| 55 | + * Define the page title when editing an attribute |
|
| 56 | + */ |
|
| 57 | 57 | const pageTitle = 'Attributes unit list'; |
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | - * Define the path to page main icon |
|
| 61 | - */ |
|
| 60 | + * Define the path to page main icon |
|
| 61 | + */ |
|
| 62 | 62 | public $pageIcon = ''; |
| 63 | 63 | /** |
| 64 | - * Define the message to output after an action |
|
| 65 | - */ |
|
| 64 | + * Define the message to output after an action |
|
| 65 | + */ |
|
| 66 | 66 | public $pageMessage = ''; |
| 67 | 67 | |
| 68 | 68 | /** |
@@ -71,47 +71,47 @@ discard block |
||
| 71 | 71 | public static $currencies_cache; |
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | - * Get the url listing slug of the current class |
|
| 75 | - * |
|
| 76 | - * @return string The table of the class |
|
| 77 | - */ |
|
| 74 | + * Get the url listing slug of the current class |
|
| 75 | + * |
|
| 76 | + * @return string The table of the class |
|
| 77 | + */ |
|
| 78 | 78 | function setMessage($message) |
| 79 | 79 | { |
| 80 | 80 | $this->pageMessage = $message; |
| 81 | 81 | } |
| 82 | 82 | /** |
| 83 | - * Get the url listing slug of the current class |
|
| 84 | - * |
|
| 85 | - * @return string The table of the class |
|
| 86 | - */ |
|
| 83 | + * Get the url listing slug of the current class |
|
| 84 | + * |
|
| 85 | + * @return string The table of the class |
|
| 86 | + */ |
|
| 87 | 87 | public static function getListingSlug() |
| 88 | 88 | { |
| 89 | 89 | return self::urlSlugListing; |
| 90 | 90 | } |
| 91 | 91 | /** |
| 92 | - * Get the url edition slug of the current class |
|
| 93 | - * |
|
| 94 | - * @return string The table of the class |
|
| 95 | - */ |
|
| 92 | + * Get the url edition slug of the current class |
|
| 93 | + * |
|
| 94 | + * @return string The table of the class |
|
| 95 | + */ |
|
| 96 | 96 | public static function getEditionSlug() |
| 97 | 97 | { |
| 98 | 98 | return self::urlSlugEdition; |
| 99 | 99 | } |
| 100 | 100 | /** |
| 101 | - * Get the database table of the current class |
|
| 102 | - * |
|
| 103 | - * @return string The table of the class |
|
| 104 | - */ |
|
| 101 | + * Get the database table of the current class |
|
| 102 | + * |
|
| 103 | + * @return string The table of the class |
|
| 104 | + */ |
|
| 105 | 105 | public static function getDbTable() |
| 106 | 106 | { |
| 107 | 107 | return self::dbTable; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
| 111 | - * Define the title of the page |
|
| 112 | - * |
|
| 113 | - * @return string $title The title of the page looking at the environnement |
|
| 114 | - */ |
|
| 111 | + * Define the title of the page |
|
| 112 | + * |
|
| 113 | + * @return string $title The title of the page looking at the environnement |
|
| 114 | + */ |
|
| 115 | 115 | function pageTitle() |
| 116 | 116 | { |
| 117 | 117 | $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : ''; |
@@ -139,8 +139,8 @@ discard block |
||
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | /** |
| 142 | - * Define the different message and action after an action is send through the element interface |
|
| 143 | - */ |
|
| 142 | + * Define the different message and action after an action is send through the element interface |
|
| 143 | + */ |
|
| 144 | 144 | function elementAction() |
| 145 | 145 | { |
| 146 | 146 | global $wpdb, $initialEavData; |
@@ -270,10 +270,10 @@ discard block |
||
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | /** |
| 273 | - * Return the list page content, containing the table that present the item list |
|
| 274 | - * |
|
| 275 | - * @return string $listItemOutput The html code that output the item list |
|
| 276 | - */ |
|
| 273 | + * Return the list page content, containing the table that present the item list |
|
| 274 | + * |
|
| 275 | + * @return string $listItemOutput The html code that output the item list |
|
| 276 | + */ |
|
| 277 | 277 | public static function elementList() |
| 278 | 278 | { |
| 279 | 279 | $listItemOutput = ''; |
@@ -393,10 +393,10 @@ discard block |
||
| 393 | 393 | return $listItemOutput; |
| 394 | 394 | } |
| 395 | 395 | /** |
| 396 | - * Return the page content to add a new item |
|
| 397 | - * |
|
| 398 | - * @return string The html code that output the interface for adding a nem item |
|
| 399 | - */ |
|
| 396 | + * Return the page content to add a new item |
|
| 397 | + * |
|
| 398 | + * @return string The html code that output the interface for adding a nem item |
|
| 399 | + */ |
|
| 400 | 400 | public static function elementEdition($itemToEdit = ''){ |
| 401 | 401 | global $attribute_displayed_field; global $wpdb; |
| 402 | 402 | $dbFieldList = wpshop_database::fields_to_input(self::getDbTable()); |
@@ -493,10 +493,10 @@ discard block |
||
| 493 | 493 | return $the_form; |
| 494 | 494 | } |
| 495 | 495 | /** |
| 496 | - * Return the different button to save the item currently being added or edited |
|
| 497 | - * |
|
| 498 | - * @return string $currentPageButton The html output code with the different button to add to the interface |
|
| 499 | - */ |
|
| 496 | + * Return the different button to save the item currently being added or edited |
|
| 497 | + * |
|
| 498 | + * @return string $currentPageButton The html output code with the different button to add to the interface |
|
| 499 | + */ |
|
| 500 | 500 | function getPageFormButton($element_id = 0) |
| 501 | 501 | { |
| 502 | 502 | $action = isset($_REQUEST['action']) ? wpshop_tools::varSanitizer($_REQUEST['action']) : 'add'; |
@@ -524,14 +524,14 @@ discard block |
||
| 524 | 524 | } |
| 525 | 525 | |
| 526 | 526 | /** |
| 527 | - * Get the existing attribute list into database |
|
| 528 | - * |
|
| 529 | - * @param integer $element_id optionnal The attribute identifier we want to get. If not specify the entire list will be returned |
|
| 530 | - * @param string $element_status optionnal The status of element to get into database. Default is set to valid element |
|
| 531 | - * @param mixed $field_to_search optionnal The field we want to check the row identifier into. Default is to set id |
|
| 532 | - * |
|
| 533 | - * @return object $element_list A wordpress database object containing the attribute list |
|
| 534 | - */ |
|
| 527 | + * Get the existing attribute list into database |
|
| 528 | + * |
|
| 529 | + * @param integer $element_id optionnal The attribute identifier we want to get. If not specify the entire list will be returned |
|
| 530 | + * @param string $element_status optionnal The status of element to get into database. Default is set to valid element |
|
| 531 | + * @param mixed $field_to_search optionnal The field we want to check the row identifier into. Default is to set id |
|
| 532 | + * |
|
| 533 | + * @return object $element_list A wordpress database object containing the attribute list |
|
| 534 | + */ |
|
| 535 | 535 | public static function getElement($element_id = '', $element_status = "'valid', 'moderated'", $field_to_search = 'id'){ |
| 536 | 536 | global $wpdb; |
| 537 | 537 | $element_list = array(); |
@@ -563,8 +563,8 @@ discard block |
||
| 563 | 563 | } |
| 564 | 564 | |
| 565 | 565 | /** |
| 566 | - * |
|
| 567 | - */ |
|
| 566 | + * |
|
| 567 | + */ |
|
| 568 | 568 | public static function get_unit_list_for_group($group_id){ |
| 569 | 569 | global $wpdb; |
| 570 | 570 | $unit_list_for_group = ''; |
@@ -578,8 +578,8 @@ discard block |
||
| 578 | 578 | return $unit_list_for_group; |
| 579 | 579 | } |
| 580 | 580 | /** |
| 581 | - * |
|
| 582 | - */ |
|
| 581 | + * |
|
| 582 | + */ |
|
| 583 | 583 | public static function get_default_unit_for_group($group_id){ |
| 584 | 584 | global $wpdb; |
| 585 | 585 | $default_unit_for_group = ''; |
@@ -592,10 +592,10 @@ discard block |
||
| 592 | 592 | } |
| 593 | 593 | |
| 594 | 594 | /** |
| 595 | - * Get the unit group existing list in database |
|
| 596 | - * |
|
| 597 | - * @return object $attribute_unit_group_list The list of existing unit group |
|
| 598 | - */ |
|
| 595 | + * Get the unit group existing list in database |
|
| 596 | + * |
|
| 597 | + * @return object $attribute_unit_group_list The list of existing unit group |
|
| 598 | + */ |
|
| 599 | 599 | public static function get_unit_group($element_id = '', $element_status = "'valid', 'moderated'", $field_to_search = 'id'){ |
| 600 | 600 | global $wpdb; |
| 601 | 601 | $element_list = array(); |
@@ -628,10 +628,10 @@ discard block |
||
| 628 | 628 | // return $attribute_unit_group_list; |
| 629 | 629 | } |
| 630 | 630 | /** |
| 631 | - * Return the list page content, containing the table that present the item list |
|
| 632 | - * |
|
| 633 | - * @return string $listItemOutput The html code that output the item list |
|
| 634 | - */ |
|
| 631 | + * Return the list page content, containing the table that present the item list |
|
| 632 | + * |
|
| 633 | + * @return string $listItemOutput The html code that output the item list |
|
| 634 | + */ |
|
| 635 | 635 | public static function unit_group_list(){ |
| 636 | 636 | $listItemOutput = ''; |
| 637 | 637 | |
@@ -740,10 +740,10 @@ discard block |
||
| 740 | 740 | return $listItemOutput; |
| 741 | 741 | } |
| 742 | 742 | /** |
| 743 | - * Return the page content to add a new item |
|
| 744 | - * |
|
| 745 | - * @return string The html code that output the interface for adding a nem item |
|
| 746 | - */ |
|
| 743 | + * Return the page content to add a new item |
|
| 744 | + * |
|
| 745 | + * @return string The html code that output the interface for adding a nem item |
|
| 746 | + */ |
|
| 747 | 747 | public static function unit_group_edition($itemToEdit = ''){ |
| 748 | 748 | global $attribute_displayed_field; |
| 749 | 749 | $dbFieldList = wpshop_database::fields_to_input(WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP); |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | |
| 3 | 3 | /* Check if file is include. No direct access possible with file url */ |
| 4 | -if ( !defined( 'WPSHOP_VERSION' ) ) { |
|
| 5 | - die( __('Access is not allowed by this way', 'wpshop') ); |
|
| 4 | +if (!defined('WPSHOP_VERSION')) { |
|
| 5 | + die(__('Access is not allowed by this way', 'wpshop')); |
|
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | /** |
@@ -116,22 +116,22 @@ discard block |
||
| 116 | 116 | { |
| 117 | 117 | $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : ''; |
| 118 | 118 | $objectInEdition = isset($_REQUEST['id']) ? sanitize_key($_REQUEST['id']) : ''; |
| 119 | - $page = !empty( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; |
|
| 119 | + $page = !empty($_GET['page']) ? sanitize_text_field($_GET['page']) : ''; |
|
| 120 | 120 | |
| 121 | - $title = __(self::pageTitle, 'wpshop' ); |
|
| 122 | - if($action != '') |
|
| 121 | + $title = __(self::pageTitle, 'wpshop'); |
|
| 122 | + if ($action != '') |
|
| 123 | 123 | { |
| 124 | - if(($action == 'edit') || ($action == 'delete')) |
|
| 124 | + if (($action == 'edit') || ($action == 'delete')) |
|
| 125 | 125 | { |
| 126 | 126 | $editedItem = self::getElement($objectInEdition); |
| 127 | 127 | $title = sprintf(__(self::pageEditingTitle, 'wpshop'), str_replace("\\", "", $editedItem->frontend_label) . ' (' . $editedItem->code . ')'); |
| 128 | 128 | } |
| 129 | - elseif($action == 'add') |
|
| 129 | + elseif ($action == 'add') |
|
| 130 | 130 | { |
| 131 | 131 | $title = __(self::pageAddingTitle, 'wpshop'); |
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | - elseif((self::getEditionSlug() != self::getListingSlug()) && (sanitize_text_field($page) == self::getEditionSlug())) |
|
| 134 | + elseif ((self::getEditionSlug() != self::getListingSlug()) && (sanitize_text_field($page) == self::getEditionSlug())) |
|
| 135 | 135 | { |
| 136 | 136 | $title = __(self::pageAddingTitle, 'wpshop'); |
| 137 | 137 | } |
@@ -152,31 +152,31 @@ discard block |
||
| 152 | 152 | /****************************************************************************/ |
| 153 | 153 | $action = isset($_REQUEST['action']) ? wpshop_tools::varSanitizer($_REQUEST['action']) : 'add'; |
| 154 | 154 | $saveditem = isset($_REQUEST['saveditem']) ? wpshop_tools::varSanitizer($_REQUEST['saveditem']) : ''; |
| 155 | - if(($action != '') && ($action == 'saveok') && ($saveditem > 0)) |
|
| 155 | + if (($action != '') && ($action == 'saveok') && ($saveditem > 0)) |
|
| 156 | 156 | { |
| 157 | 157 | $editedElement = self::getElement($saveditem); |
| 158 | 158 | $pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully saved', 'wpshop'), '<span class="bold" >' . $editedElement->code . '</span>'); |
| 159 | 159 | } |
| 160 | - elseif(($action != '') && ($action == 'deleteok') && ($saveditem > 0)) |
|
| 160 | + elseif (($action != '') && ($action == 'deleteok') && ($saveditem > 0)) |
|
| 161 | 161 | { |
| 162 | 162 | $editedElement = self::getElement($saveditem, "'deleted'"); |
| 163 | 163 | $pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully deleted', 'wpshop'), '<span class="bold" >' . $editedElement->code . '</span>'); |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | /* Define the database operation type from action launched by the user */ |
| 167 | - $attribute_group_parameter = (!empty($_REQUEST[self::getDbTable()])) ? (array) $_REQUEST[self::getDbTable()] : array(); |
|
| 168 | - $attribute_group_parameter['default_value'] = str_replace('"', "'", sanitize_text_field( $attribute_group_parameter['default_value'])); |
|
| 167 | + $attribute_group_parameter = (!empty($_REQUEST[self::getDbTable()])) ? (array)$_REQUEST[self::getDbTable()] : array(); |
|
| 168 | + $attribute_group_parameter['default_value'] = str_replace('"', "'", sanitize_text_field($attribute_group_parameter['default_value'])); |
|
| 169 | 169 | /************************* GENERIC **************************/ |
| 170 | 170 | /*************************************************************************/ |
| 171 | 171 | $pageAction = isset($_REQUEST[self::getDbTable() . '_action']) ? wpshop_tools::varSanitizer($_REQUEST[self::getDbTable() . '_action']) : ''; |
| 172 | 172 | $id = isset($attribute_group_parameter['id']) ? sanitize_key($attribute_group_parameter['id']) : ''; |
| 173 | - if(($pageAction != '') && (($pageAction == 'edit') || ($pageAction == 'editandcontinue'))){ |
|
| 174 | - if(current_user_can('wpshop_edit_attributes')) |
|
| 173 | + if (($pageAction != '') && (($pageAction == 'edit') || ($pageAction == 'editandcontinue'))) { |
|
| 174 | + if (current_user_can('wpshop_edit_attributes')) |
|
| 175 | 175 | { |
| 176 | 176 | $attribute_group_parameter['last_update_date'] = date('Y-m-d H:i:s'); |
| 177 | - if($pageAction == 'delete') |
|
| 177 | + if ($pageAction == 'delete') |
|
| 178 | 178 | { |
| 179 | - if(current_user_can('wpshop_delete_attributes')) |
|
| 179 | + if (current_user_can('wpshop_delete_attributes')) |
|
| 180 | 180 | { |
| 181 | 181 | $attribute_group_parameter['status'] = 'deleted'; |
| 182 | 182 | } |
@@ -192,8 +192,8 @@ discard block |
||
| 192 | 192 | $actionResult = 'userNotAllowedForActionEdit'; |
| 193 | 193 | } |
| 194 | 194 | } |
| 195 | - elseif(($pageAction != '') && (($pageAction == 'delete'))){ |
|
| 196 | - if(current_user_can('wpshop_delete_attributes')) |
|
| 195 | + elseif (($pageAction != '') && (($pageAction == 'delete'))) { |
|
| 196 | + if (current_user_can('wpshop_delete_attributes')) |
|
| 197 | 197 | { |
| 198 | 198 | $attribute_group_parameter['last_update_date'] = date('Y-m-d H:i:s'); |
| 199 | 199 | $attribute_group_parameter['status'] = 'deleted'; |
@@ -204,21 +204,21 @@ discard block |
||
| 204 | 204 | $actionResult = 'userNotAllowedForActionDelete'; |
| 205 | 205 | } |
| 206 | 206 | } |
| 207 | - elseif(($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))){ |
|
| 208 | - if(current_user_can('wpshop_add_attributes')){ |
|
| 207 | + elseif (($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))) { |
|
| 208 | + if (current_user_can('wpshop_add_attributes')) { |
|
| 209 | 209 | $attribute_group_parameter['creation_date'] = date('Y-m-d H:i:s'); |
| 210 | - if(trim($attribute_group_parameter['code']) == ''){ |
|
| 210 | + if (trim($attribute_group_parameter['code']) == '') { |
|
| 211 | 211 | $attribute_group_parameter['code'] = $attribute_group_parameter['frontend_label']; |
| 212 | 212 | } |
| 213 | 213 | $attribute_group_parameter['code'] = wpshop_tools::slugify(str_replace("\'", "_", str_replace('\"', "_", $attribute_group_parameter['code'])), array('noAccent', 'noSpaces', 'lowerCase', 'noPunctuation')); |
| 214 | 214 | $code_exists = self::getElement($attribute_group_parameter['code'], "'valid', 'moderated', 'deleted'", 'code'); |
| 215 | - if((is_object($code_exists) || is_array($code_exists)) && (count($code_exists) > 0)){ |
|
| 215 | + if ((is_object($code_exists) || is_array($code_exists)) && (count($code_exists) > 0)) { |
|
| 216 | 216 | $attribute_group_parameter['code'] = $attribute_group_parameter['code'] . '_' . (count($code_exists) + 1); |
| 217 | 217 | } |
| 218 | 218 | $actionResult = wpshop_database::save($attribute_group_parameter, self::getDbTable()); |
| 219 | 219 | $id = $wpdb->insert_id; |
| 220 | 220 | } |
| 221 | - else{ |
|
| 221 | + else { |
|
| 222 | 222 | $actionResult = 'userNotAllowedForActionAdd'; |
| 223 | 223 | } |
| 224 | 224 | } |
@@ -228,16 +228,16 @@ discard block |
||
| 228 | 228 | /************ CHANGE THE FIELD NAME TO TAKE TO DISPLAY *************/ |
| 229 | 229 | /************ CHANGE ERROR MESSAGE FOR SPECIFIC CASE *************/ |
| 230 | 230 | /****************************************************************************/ |
| 231 | - if($actionResult != ''){ |
|
| 231 | + if ($actionResult != '') { |
|
| 232 | 232 | $elementIdentifierForMessage = '<span class="bold" >' . $attribute_group_parameter['frontend_label'] . '</span>'; |
| 233 | 233 | if ($actionResult == 'error') { |
| 234 | 234 | $pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . sprintf(__('An error occured while saving %s', 'wpshop'), $elementIdentifierForMessage); |
| 235 | - if(WPSHOP_DEBUG_MODE) |
|
| 235 | + if (WPSHOP_DEBUG_MODE) |
|
| 236 | 236 | { |
| 237 | 237 | $pageMessage .= '<br/>' . $wpdb->last_error; |
| 238 | 238 | } |
| 239 | 239 | } |
| 240 | - elseif(($actionResult == 'done') || ($actionResult == 'nothingToUpdate')) |
|
| 240 | + elseif (($actionResult == 'done') || ($actionResult == 'nothingToUpdate')) |
|
| 241 | 241 | {/* CHANGE HERE FOR SPECIFIC CASE */ |
| 242 | 242 | /*****************************************************************************************************************/ |
| 243 | 243 | /************************* CHANGE FOR SPECIFIC ACTION FOR CURRENT ELEMENT ******************/ |
@@ -247,20 +247,20 @@ discard block |
||
| 247 | 247 | /************************* GENERIC ****************************/ |
| 248 | 248 | /***********************************************************************************/ |
| 249 | 249 | $pageMessage .= '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully saved', 'wpshop'), $elementIdentifierForMessage); |
| 250 | - if(($pageAction == 'edit') || ($pageAction == 'save')) |
|
| 250 | + if (($pageAction == 'edit') || ($pageAction == 'save')) |
|
| 251 | 251 | { |
| 252 | 252 | wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=saveok&saveditem=" . $id)); |
| 253 | 253 | } |
| 254 | - elseif($pageAction == 'add') |
|
| 254 | + elseif ($pageAction == 'add') |
|
| 255 | 255 | { |
| 256 | 256 | wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=edit&id=" . $id)); |
| 257 | 257 | } |
| 258 | - elseif($pageAction == 'delete') |
|
| 258 | + elseif ($pageAction == 'delete') |
|
| 259 | 259 | { |
| 260 | 260 | wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=deleteok&saveditem=" . $id)); |
| 261 | 261 | } |
| 262 | 262 | } |
| 263 | - elseif(($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete')) |
|
| 263 | + elseif (($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete')) |
|
| 264 | 264 | { |
| 265 | 265 | $pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . __('You are not allowed to do this action', 'wpshop'); |
| 266 | 266 | } |
@@ -292,36 +292,36 @@ discard block |
||
| 292 | 292 | |
| 293 | 293 | $line = 0; |
| 294 | 294 | $elementList = self::getElement(); |
| 295 | - if(is_array($elementList) && (count($elementList) > 0)){ |
|
| 296 | - foreach($elementList as $element) |
|
| 295 | + if (is_array($elementList) && (count($elementList) > 0)) { |
|
| 296 | + foreach ($elementList as $element) |
|
| 297 | 297 | { |
| 298 | 298 | $tableRowsId[$line] = self::getDbTable() . '_' . $element->id; |
| 299 | 299 | |
| 300 | 300 | $elementLabel = __($element->name, 'wpshop'); |
| 301 | 301 | $subRowActions = ''; |
| 302 | 302 | $attributeSlugUrl = self::getListingSlug(); |
| 303 | - if(current_user_can('wpshop_add_attributes_unit')) |
|
| 303 | + if (current_user_can('wpshop_add_attributes_unit')) |
|
| 304 | 304 | { |
| 305 | 305 | $attributeSlugUrl = self::getEditionSlug(); |
| 306 | 306 | } |
| 307 | - if(current_user_can('wpshop_edit_attributes_unit')) |
|
| 307 | + if (current_user_can('wpshop_edit_attributes_unit')) |
|
| 308 | 308 | { |
| 309 | 309 | $editAction = admin_url('admin.php?page=' . $attributeSlugUrl . '&action=edit&id=' . $element->id); |
| 310 | 310 | $subRowActions .= ' |
| 311 | - <a href="#" id="edit_attribute_unit_' . $element->id . '" class="edit_attribute_unit" data-nonce="' . wp_create_nonce( 'edit_attribute_unit_' . $element->id ) . '" >' . __('Edit', 'wpshop') . '</a>'; |
|
| 311 | + <a href="#" id="edit_attribute_unit_' . $element->id . '" class="edit_attribute_unit" data-nonce="' . wp_create_nonce('edit_attribute_unit_' . $element->id) . '" >' . __('Edit', 'wpshop') . '</a>'; |
|
| 312 | 312 | } |
| 313 | - elseif(current_user_can('wpshop_view_attributes_unit')) |
|
| 313 | + elseif (current_user_can('wpshop_view_attributes_unit')) |
|
| 314 | 314 | { |
| 315 | 315 | $editAction = admin_url('admin.php?page=' . $attributeSlugUrl . '&action=edit&id=' . $element->id); |
| 316 | 316 | } |
| 317 | - if(current_user_can('wpshop_delete_attributes_unit')) |
|
| 317 | + if (current_user_can('wpshop_delete_attributes_unit')) |
|
| 318 | 318 | { |
| 319 | - if($subRowActions != '') |
|
| 319 | + if ($subRowActions != '') |
|
| 320 | 320 | { |
| 321 | 321 | $subRowActions .= ' | '; |
| 322 | 322 | } |
| 323 | 323 | $subRowActions .= ' |
| 324 | - <a href="#" id="delete_attribute_unit_' . $element->id . '" class="delete_attribute_unit" data-nonce="' . wp_create_nonce( 'delete_attribute_unit_' . $element->id ) . '" >' . __('Delete', 'wpshop') . '</a>'; |
|
| 324 | + <a href="#" id="delete_attribute_unit_' . $element->id . '" class="delete_attribute_unit" data-nonce="' . wp_create_nonce('delete_attribute_unit_' . $element->id) . '" >' . __('Delete', 'wpshop') . '</a>'; |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | $rowActions = ' |
@@ -337,14 +337,14 @@ discard block |
||
| 337 | 337 | $line++; |
| 338 | 338 | } |
| 339 | 339 | } |
| 340 | - else{ |
|
| 340 | + else { |
|
| 341 | 341 | unset($tableRowValue); |
| 342 | 342 | $tableRowValue[] = array('class' => self::currentPageCode . '_label_cell', 'value' => __('No element to ouput here', 'wpshop')); |
| 343 | 343 | $tableRowValue[] = array('class' => self::currentPageCode . '_name_cell', 'value' => ''); |
| 344 | 344 | $tableRowValue[] = array('class' => self::currentPageCode . '_code_cell', 'value' => ''); |
| 345 | 345 | $tableRows[] = $tableRowValue; |
| 346 | 346 | } |
| 347 | - if(current_user_can('wpshop_add_attributes_unit')){ |
|
| 347 | + if (current_user_can('wpshop_add_attributes_unit')) { |
|
| 348 | 348 | $listItemOutput .= ' |
| 349 | 349 | <input type="button" value="' . __('Add an unit', 'wpshop') . '" class="button-secondary alignleft" name="add_attribute_unit" id="add_attribute_unit" />'; |
| 350 | 350 | } |
@@ -353,11 +353,11 @@ discard block |
||
| 353 | 353 | wpshop(document).ready(function(){ |
| 354 | 354 | jQuery("#' . $tableId . '").dataTable(); |
| 355 | 355 | jQuery("#wpshop_unit_group_list_tab").show();'; |
| 356 | - if(current_user_can('wpshop_delete_attributes_unit')){ |
|
| 356 | + if (current_user_can('wpshop_delete_attributes_unit')) { |
|
| 357 | 357 | $listItemOutput .= ' |
| 358 | 358 | wpshop(document).on("click", ".delete_attribute_unit", function() { |
| 359 | 359 | var nonce = jQuery( this ).data( "nonce" ); |
| 360 | - if(confirm(wpshopConvertAccentTojs("' . __('Are you sure you want to delete this unit', 'wpshop') .' ?"))){ |
|
| 360 | + if(confirm(wpshopConvertAccentTojs("' . __('Are you sure you want to delete this unit', 'wpshop') . ' ?"))){ |
|
| 361 | 361 | wpshop("#wpshop_unit_list").load(ajaxurl,{ |
| 362 | 362 | "action": "wps_attribute_unit_delete", |
| 363 | 363 | "elementIdentifier": wpshop(this).attr("id").replace("delete_attribute_unit_", ""), |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | } |
| 367 | 367 | });'; |
| 368 | 368 | } |
| 369 | - if(current_user_can('wpshop_edit_attributes_unit')){ |
|
| 369 | + if (current_user_can('wpshop_edit_attributes_unit')) { |
|
| 370 | 370 | $listItemOutput .= ' |
| 371 | 371 | wpshop(document).on("click", ".edit_attribute_unit", function() { |
| 372 | 372 | var nonce = jQuery( this ).data( "nonce" ); |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | }); |
| 378 | 378 | });'; |
| 379 | 379 | } |
| 380 | - if(current_user_can('wpshop_add_attributes_unit')){ |
|
| 380 | + if (current_user_can('wpshop_add_attributes_unit')) { |
|
| 381 | 381 | $listItemOutput .= ' |
| 382 | 382 | jQuery("#add_attribute_unit").click(function(){ |
| 383 | 383 | jQuery("#wpshop_unit_list").load(ajaxurl,{ |
@@ -397,34 +397,34 @@ discard block |
||
| 397 | 397 | * |
| 398 | 398 | * @return string The html code that output the interface for adding a nem item |
| 399 | 399 | */ |
| 400 | - public static function elementEdition($itemToEdit = ''){ |
|
| 400 | + public static function elementEdition($itemToEdit = '') { |
|
| 401 | 401 | global $attribute_displayed_field; global $wpdb; |
| 402 | 402 | $dbFieldList = wpshop_database::fields_to_input(self::getDbTable()); |
| 403 | 403 | |
| 404 | 404 | $editedItem = ''; |
| 405 | 405 | // @TODO : Request |
| 406 | 406 | // $_REQUEST['action'] = 'save_new_attribute_unit'; |
| 407 | - if($itemToEdit != ''){ |
|
| 407 | + if ($itemToEdit != '') { |
|
| 408 | 408 | $editedItem = self::getElement($itemToEdit); |
| 409 | 409 | // $_REQUEST['action'] = 'update_attribute_unit'; |
| 410 | 410 | } |
| 411 | - $query = $wpdb->prepare('SELECT unit FROM ' .WPSHOP_DBT_ATTRIBUTE_UNIT. ' WHERE id = ' .get_option('wpshop_shop_default_currency'). '', ''); |
|
| 411 | + $query = $wpdb->prepare('SELECT unit FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id = ' . get_option('wpshop_shop_default_currency') . '', ''); |
|
| 412 | 412 | $default_unit = $wpdb->get_var($query); |
| 413 | 413 | |
| 414 | 414 | $the_form_content_hidden = $the_form_general_content = $the_form_option_content = ''; |
| 415 | - foreach($dbFieldList as $input_key => $input_def){ |
|
| 415 | + foreach ($dbFieldList as $input_key => $input_def) { |
|
| 416 | 416 | $pageAction = isset($_REQUEST[self::getDbTable() . '_action']) ? sanitize_text_field($_REQUEST[self::getDbTable() . '_action']) : ''; |
| 417 | 417 | $requestFormValue = isset($_REQUEST[self::currentPageCode][$input_def['name']]) ? sanitize_text_field($_REQUEST[self::currentPageCode][$input_def['name']]) : ''; |
| 418 | 418 | $currentFieldValue = $input_def['value']; |
| 419 | - if(is_object($editedItem)){ |
|
| 419 | + if (is_object($editedItem)) { |
|
| 420 | 420 | $currentFieldValue = $editedItem->{$input_def['name']}; |
| 421 | 421 | } |
| 422 | - elseif(($pageAction != '') && ($requestFormValue != '')){ |
|
| 422 | + elseif (($pageAction != '') && ($requestFormValue != '')) { |
|
| 423 | 423 | $currentFieldValue = $requestFormValue; |
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | $input_def['value'] = $currentFieldValue; |
| 427 | - if($input_def['name'] == 'group_id'){ |
|
| 427 | + if ($input_def['name'] == 'group_id') { |
|
| 428 | 428 | $attribute_unit_group_list = self::get_unit_group(); |
| 429 | 429 | $input_def['possible_value'] = $attribute_unit_group_list; |
| 430 | 430 | $input_def['type'] = 'select'; |
@@ -434,9 +434,9 @@ discard block |
||
| 434 | 434 | $the_input = wpshop_form::check_input_type($input_def, self::getDbTable()); |
| 435 | 435 | |
| 436 | 436 | |
| 437 | - if($input_def['type'] != 'hidden'){ |
|
| 437 | + if ($input_def['type'] != 'hidden') { |
|
| 438 | 438 | $label = 'for="' . $input_def['name'] . '"'; |
| 439 | - if(($input_def['type'] == 'radio') || ($input_def['type'] == 'checkbox')){ |
|
| 439 | + if (($input_def['type'] == 'radio') || ($input_def['type'] == 'checkbox')) { |
|
| 440 | 440 | $label = ''; |
| 441 | 441 | } |
| 442 | 442 | |
@@ -446,29 +446,29 @@ discard block |
||
| 446 | 446 | <label ' . $label . ' >' . __($input_def['name'], 'wpshop') . '</label> |
| 447 | 447 | </div> |
| 448 | 448 | <div class="wpshop_form_input wpshop_' . self::currentPageCode . '_' . $input_def['name'] . '_input alignleft" > |
| 449 | - ' . $the_input . ' ' .( ($input_def['name'] == 'change_rate') ? $default_unit : ''). ' |
|
| 449 | + ' . $the_input . ' ' . (($input_def['name'] == 'change_rate') ? $default_unit : '') . ' |
|
| 450 | 450 | </div> |
| 451 | 451 | </div>'; |
| 452 | 452 | |
| 453 | 453 | |
| 454 | 454 | } |
| 455 | - else{ |
|
| 455 | + else { |
|
| 456 | 456 | $the_form_content_hidden .= ' |
| 457 | 457 | ' . $the_input; |
| 458 | 458 | } |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | - $the_form = '<form name="' . self::getDbTable() . '_form" id="' . self::getDbTable() . '_form" method="post" action="' . admin_url( 'admin-ajax.php' ) . '" >'; |
|
| 462 | - if( ctype_digit( (string) $itemToEdit ) ) { |
|
| 461 | + $the_form = '<form name="' . self::getDbTable() . '_form" id="' . self::getDbTable() . '_form" method="post" action="' . admin_url('admin-ajax.php') . '" >'; |
|
| 462 | + if (ctype_digit((string)$itemToEdit)) { |
|
| 463 | 463 | $the_form .= wpshop_form::form_input('action', 'action', 'wps_attribute_unit_update', 'hidden'); |
| 464 | - $the_form .= wp_nonce_field( 'update_attribute_unit', '_wpnonce' ); |
|
| 464 | + $the_form .= wp_nonce_field('update_attribute_unit', '_wpnonce'); |
|
| 465 | 465 | } else { |
| 466 | 466 | $the_form .= wpshop_form::form_input('action', 'action', 'wps_attribute_unit_new', 'hidden'); |
| 467 | - $the_form .= wp_nonce_field( 'save_new_attribute_unit', '_wpnonce' ); |
|
| 467 | + $the_form .= wp_nonce_field('save_new_attribute_unit', '_wpnonce'); |
|
| 468 | 468 | } |
| 469 | - $the_form .= wpshop_form::form_input(self::currentPageCode . '_form_has_modification', self::currentPageCode . '_form_has_modification', 'no' , 'hidden'); |
|
| 469 | + $the_form .= wpshop_form::form_input(self::currentPageCode . '_form_has_modification', self::currentPageCode . '_form_has_modification', 'no', 'hidden'); |
|
| 470 | 470 | $the_form .= $the_form_content_hidden . $the_form_general_content; |
| 471 | - $the_form .= '<input type="button" value="' . __('Back', 'wpshop') . '" class="button-primary alignright" name="cancel_unit_edition" id="cancel_unit_edition" data-nonce="' . wp_create_nonce( 'load_attribute_units' ) . '" /> |
|
| 471 | + $the_form .= '<input type="button" value="' . __('Back', 'wpshop') . '" class="button-primary alignright" name="cancel_unit_edition" id="cancel_unit_edition" data-nonce="' . wp_create_nonce('load_attribute_units') . '" /> |
|
| 472 | 472 | <input type="submit" value="' . __('Save', 'wpshop') . '" class="button-primary alignright" name="save_new_unit" id="save_new_unit" /> |
| 473 | 473 | </form> |
| 474 | 474 | <script type="text/javascript" > |
@@ -502,18 +502,18 @@ discard block |
||
| 502 | 502 | $action = isset($_REQUEST['action']) ? wpshop_tools::varSanitizer($_REQUEST['action']) : 'add'; |
| 503 | 503 | $currentPageButton = ''; |
| 504 | 504 | |
| 505 | - if($action == 'add') |
|
| 505 | + if ($action == 'add') |
|
| 506 | 506 | { |
| 507 | - if(current_user_can('wpshop_add_attributes')) |
|
| 507 | + if (current_user_can('wpshop_add_attributes')) |
|
| 508 | 508 | { |
| 509 | 509 | $currentPageButton .= '<input type="button" class="button-primary" id="add" name="add" value="' . __('Add', 'wpshop') . '" />'; |
| 510 | 510 | } |
| 511 | 511 | } |
| 512 | - elseif(current_user_can('wpshop_edit_attributes')) |
|
| 512 | + elseif (current_user_can('wpshop_edit_attributes')) |
|
| 513 | 513 | { |
| 514 | 514 | $currentPageButton .= '<input type="button" class="button-primary" id="save" name="save" value="' . __('Save', 'wpshop') . '" /><input type="button" class="button-primary" id="saveandcontinue" name="saveandcontinue" value="' . __('Save and continue edit', 'wpshop') . '" />'; |
| 515 | 515 | } |
| 516 | - if(current_user_can('wpshop_delete_attributes') && ($action != 'add')) |
|
| 516 | + if (current_user_can('wpshop_delete_attributes') && ($action != 'add')) |
|
| 517 | 517 | { |
| 518 | 518 | $currentPageButton .= '<input type="button" class="button-primary" id="delete" name="delete" value="' . __('Delete', 'wpshop') . '" />'; |
| 519 | 519 | } |
@@ -532,13 +532,13 @@ discard block |
||
| 532 | 532 | * |
| 533 | 533 | * @return object $element_list A wordpress database object containing the attribute list |
| 534 | 534 | */ |
| 535 | - public static function getElement($element_id = '', $element_status = "'valid', 'moderated'", $field_to_search = 'id'){ |
|
| 535 | + public static function getElement($element_id = '', $element_status = "'valid', 'moderated'", $field_to_search = 'id') { |
|
| 536 | 536 | global $wpdb; |
| 537 | 537 | $element_list = array(); |
| 538 | 538 | $moreQuery = ""; |
| 539 | - $moreQueryArgs = array( 1, ); |
|
| 539 | + $moreQueryArgs = array(1,); |
|
| 540 | 540 | |
| 541 | - if($element_id != ''){ |
|
| 541 | + if ($element_id != '') { |
|
| 542 | 542 | $moreQuery = " |
| 543 | 543 | AND CURRENT_ELEMENT." . $field_to_search . " = %s "; |
| 544 | 544 | $moreQueryArgs[] = $element_id; |
@@ -548,14 +548,14 @@ discard block |
||
| 548 | 548 | "SELECT CURRENT_ELEMENT.*, UNIT_GROUP.name as group_name |
| 549 | 549 | FROM " . self::getDbTable() . " AS CURRENT_ELEMENT |
| 550 | 550 | LEFT JOIN " . WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . " AS UNIT_GROUP ON (UNIT_GROUP.id = CURRENT_ELEMENT.group_id) |
| 551 | - WHERE %d AND CURRENT_ELEMENT.status IN (".$element_status.") " . $moreQuery, $moreQueryArgs |
|
| 551 | + WHERE %d AND CURRENT_ELEMENT.status IN (".$element_status . ") " . $moreQuery, $moreQueryArgs |
|
| 552 | 552 | ); |
| 553 | 553 | |
| 554 | 554 | /* Get the query result regarding on the function parameters. If there must be only one result or a collection */ |
| 555 | - if($element_id == ''){ |
|
| 555 | + if ($element_id == '') { |
|
| 556 | 556 | $element_list = $wpdb->get_results($query); |
| 557 | 557 | } |
| 558 | - else{ |
|
| 558 | + else { |
|
| 559 | 559 | $element_list = $wpdb->get_row($query); |
| 560 | 560 | } |
| 561 | 561 | |
@@ -565,7 +565,7 @@ discard block |
||
| 565 | 565 | /** |
| 566 | 566 | * |
| 567 | 567 | */ |
| 568 | - public static function get_unit_list_for_group($group_id){ |
|
| 568 | + public static function get_unit_list_for_group($group_id) { |
|
| 569 | 569 | global $wpdb; |
| 570 | 570 | $unit_list_for_group = ''; |
| 571 | 571 | |
@@ -580,7 +580,7 @@ discard block |
||
| 580 | 580 | /** |
| 581 | 581 | * |
| 582 | 582 | */ |
| 583 | - public static function get_default_unit_for_group($group_id){ |
|
| 583 | + public static function get_default_unit_for_group($group_id) { |
|
| 584 | 584 | global $wpdb; |
| 585 | 585 | $default_unit_for_group = ''; |
| 586 | 586 | |
@@ -596,13 +596,13 @@ discard block |
||
| 596 | 596 | * |
| 597 | 597 | * @return object $attribute_unit_group_list The list of existing unit group |
| 598 | 598 | */ |
| 599 | - public static function get_unit_group($element_id = '', $element_status = "'valid', 'moderated'", $field_to_search = 'id'){ |
|
| 599 | + public static function get_unit_group($element_id = '', $element_status = "'valid', 'moderated'", $field_to_search = 'id') { |
|
| 600 | 600 | global $wpdb; |
| 601 | 601 | $element_list = array(); |
| 602 | 602 | $moreQuery = ""; |
| 603 | - $moreQueryArgs = array( 1, ); |
|
| 603 | + $moreQueryArgs = array(1,); |
|
| 604 | 604 | |
| 605 | - if($element_id != ''){ |
|
| 605 | + if ($element_id != '') { |
|
| 606 | 606 | $moreQuery = " |
| 607 | 607 | AND CURRENT_ELEMENT." . $field_to_search . " = %d "; |
| 608 | 608 | $moreQueryArgs[] = $element_id; |
@@ -611,11 +611,11 @@ discard block |
||
| 611 | 611 | $query = $wpdb->prepare( |
| 612 | 612 | "SELECT CURRENT_ELEMENT.* |
| 613 | 613 | FROM " . WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . " AS CURRENT_ELEMENT |
| 614 | - WHERE %d AND CURRENT_ELEMENT.status IN (".$element_status.") " . $moreQuery, $moreQueryArgs |
|
| 614 | + WHERE %d AND CURRENT_ELEMENT.status IN (".$element_status . ") " . $moreQuery, $moreQueryArgs |
|
| 615 | 615 | ); |
| 616 | 616 | |
| 617 | 617 | /* Get the query result regarding on the function parameters. If there must be only one result or a collection */ |
| 618 | - if($element_id == '') |
|
| 618 | + if ($element_id == '') |
|
| 619 | 619 | $element_list = $wpdb->get_results($query); |
| 620 | 620 | else |
| 621 | 621 | $element_list = $wpdb->get_row($query); |
@@ -632,7 +632,7 @@ discard block |
||
| 632 | 632 | * |
| 633 | 633 | * @return string $listItemOutput The html code that output the item list |
| 634 | 634 | */ |
| 635 | - public static function unit_group_list(){ |
|
| 635 | + public static function unit_group_list() { |
|
| 636 | 636 | $listItemOutput = ''; |
| 637 | 637 | |
| 638 | 638 | /* Start the table definition */ |
@@ -645,36 +645,36 @@ discard block |
||
| 645 | 645 | |
| 646 | 646 | $line = 0; |
| 647 | 647 | $elementList = self::get_unit_group(); |
| 648 | - if(is_array($elementList) && (count($elementList) > 0)){ |
|
| 649 | - foreach($elementList as $element) |
|
| 648 | + if (is_array($elementList) && (count($elementList) > 0)) { |
|
| 649 | + foreach ($elementList as $element) |
|
| 650 | 650 | { |
| 651 | 651 | $tableRowsId[$line] = self::getDbTable() . '_' . $element->id; |
| 652 | 652 | |
| 653 | 653 | $elementLabel = __($element->name, 'wpshop'); |
| 654 | 654 | $subRowActions = ''; |
| 655 | 655 | $attributeSlugUrl = self::getListingSlug(); |
| 656 | - if(current_user_can('wpshop_add_attributes_unit_group')) |
|
| 656 | + if (current_user_can('wpshop_add_attributes_unit_group')) |
|
| 657 | 657 | { |
| 658 | 658 | $attributeSlugUrl = self::getEditionSlug(); |
| 659 | 659 | } |
| 660 | - if(current_user_can('wpshop_edit_attributes_unit_group')) |
|
| 660 | + if (current_user_can('wpshop_edit_attributes_unit_group')) |
|
| 661 | 661 | { |
| 662 | 662 | $editAction = admin_url('admin.php?page=' . $attributeSlugUrl . '&action=edit&id=' . $element->id); |
| 663 | 663 | $subRowActions .= ' |
| 664 | - <a href="#" id="edit_attribute_unit_group_' . $element->id . '" class="edit_attribute_unit_group" data-nonce="' . wp_create_nonce( 'edit_attribute_unit_group_' . $element->id ) . '" >' . __('Edit', 'wpshop') . '</a>'; |
|
| 664 | + <a href="#" id="edit_attribute_unit_group_' . $element->id . '" class="edit_attribute_unit_group" data-nonce="' . wp_create_nonce('edit_attribute_unit_group_' . $element->id) . '" >' . __('Edit', 'wpshop') . '</a>'; |
|
| 665 | 665 | } |
| 666 | - elseif(current_user_can('wpshop_view_attributes_unit_group')) |
|
| 666 | + elseif (current_user_can('wpshop_view_attributes_unit_group')) |
|
| 667 | 667 | { |
| 668 | 668 | $editAction = admin_url('admin.php?page=' . $attributeSlugUrl . '&action=edit&id=' . $element->id); |
| 669 | 669 | } |
| 670 | - if(current_user_can('wpshop_delete_attributes_unit_group')) |
|
| 670 | + if (current_user_can('wpshop_delete_attributes_unit_group')) |
|
| 671 | 671 | { |
| 672 | - if($subRowActions != '') |
|
| 672 | + if ($subRowActions != '') |
|
| 673 | 673 | { |
| 674 | 674 | $subRowActions .= ' | '; |
| 675 | 675 | } |
| 676 | 676 | $subRowActions .= ' |
| 677 | - <a href="#" id="delete_attribute_unit_group_' . $element->id . '" class="delete_attribute_unit_group" data-nonce="' . wp_create_nonce( 'delete_attribute_unit_group_' . $element->id ) . '" >' . __('Delete', 'wpshop') . '</a>'; |
|
| 677 | + <a href="#" id="delete_attribute_unit_group_' . $element->id . '" class="delete_attribute_unit_group" data-nonce="' . wp_create_nonce('delete_attribute_unit_group_' . $element->id) . '" >' . __('Delete', 'wpshop') . '</a>'; |
|
| 678 | 678 | } |
| 679 | 679 | |
| 680 | 680 | $rowActions = ' |
@@ -688,24 +688,24 @@ discard block |
||
| 688 | 688 | $line++; |
| 689 | 689 | } |
| 690 | 690 | } |
| 691 | - else{ |
|
| 691 | + else { |
|
| 692 | 692 | unset($tableRowValue); |
| 693 | 693 | $tableRowValue[] = array('class' => self::currentPageCode . '_label_cell', 'value' => __('No element to ouput here', 'wpshop')); |
| 694 | 694 | $tableRows[] = $tableRowValue; |
| 695 | 695 | } |
| 696 | - if(current_user_can('wpshop_add_attributes_unit_group')){ |
|
| 696 | + if (current_user_can('wpshop_add_attributes_unit_group')) { |
|
| 697 | 697 | $listItemOutput .= ' |
| 698 | -<input type="button" value="' . __('Add an unit group', 'wpshop') . '" class="button-secondary alignleft" name="add_attribute_unit_group" id="add_attribute_unit_group" data-nonce="' . wp_create_nonce( 'add_attribute_unit_group' ) . '" />'; |
|
| 698 | +<input type="button" value="' . __('Add an unit group', 'wpshop') . '" class="button-secondary alignleft" name="add_attribute_unit_group" id="add_attribute_unit_group" data-nonce="' . wp_create_nonce('add_attribute_unit_group') . '" />'; |
|
| 699 | 699 | } |
| 700 | 700 | $listItemOutput .= wpshop_display::getTable($tableId, $tableTitles, $tableRows, $tableClasses, $tableRowsId, $tableSummary, true) . ' |
| 701 | 701 | <script type="text/javascript" > |
| 702 | 702 | wpshop(document).ready(function(){ |
| 703 | 703 | jQuery("#' . $tableId . '").dataTable(); |
| 704 | 704 | jQuery("#wpshop_unit_list_tab").show();'; |
| 705 | - if(current_user_can('wpshop_delete_attributes_unit_group')){ |
|
| 705 | + if (current_user_can('wpshop_delete_attributes_unit_group')) { |
|
| 706 | 706 | $listItemOutput .= ' |
| 707 | 707 | wpshop(document).on("click", ".delete_attribute_unit_group", function() { |
| 708 | - if(confirm(wpshopConvertAccentTojs("' . __('Are you sure you want to delete this unit group', 'wpshop') .' ?"))){ |
|
| 708 | + if(confirm(wpshopConvertAccentTojs("' . __('Are you sure you want to delete this unit group', 'wpshop') . ' ?"))){ |
|
| 709 | 709 | wpshop("#wpshop_unit_group_list").load(ajaxurl, { |
| 710 | 710 | "action": "wps_attribute_group_unit_delete", |
| 711 | 711 | "elementIdentifier": wpshop(this).attr("id").replace("delete_attribute_unit_group_", ""), |
@@ -714,7 +714,7 @@ discard block |
||
| 714 | 714 | } |
| 715 | 715 | });'; |
| 716 | 716 | } |
| 717 | - if(current_user_can('wpshop_edit_attributes_unit_group')){ |
|
| 717 | + if (current_user_can('wpshop_edit_attributes_unit_group')) { |
|
| 718 | 718 | $listItemOutput .= ' |
| 719 | 719 | wpshop(document).on("click", ".edit_attribute_unit_group", function() { |
| 720 | 720 | wpshop("#wpshop_unit_group_list").load(ajaxurl, { |
@@ -724,7 +724,7 @@ discard block |
||
| 724 | 724 | }); |
| 725 | 725 | });'; |
| 726 | 726 | } |
| 727 | - if(current_user_can('wpshop_add_attributes_unit_group')){ |
|
| 727 | + if (current_user_can('wpshop_add_attributes_unit_group')) { |
|
| 728 | 728 | $listItemOutput .= ' |
| 729 | 729 | wpshop("#add_attribute_unit_group").click(function(){ |
| 730 | 730 | wpshop("#wpshop_unit_group_list").load(ajaxurl, { |
@@ -744,25 +744,25 @@ discard block |
||
| 744 | 744 | * |
| 745 | 745 | * @return string The html code that output the interface for adding a nem item |
| 746 | 746 | */ |
| 747 | - public static function unit_group_edition($itemToEdit = ''){ |
|
| 747 | + public static function unit_group_edition($itemToEdit = '') { |
|
| 748 | 748 | global $attribute_displayed_field; |
| 749 | 749 | $dbFieldList = wpshop_database::fields_to_input(WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP); |
| 750 | 750 | |
| 751 | - if( ctype_digit( (string) $itemToEdit ) ) { |
|
| 752 | - $editedItem = self::get_unit_group( (int) $itemToEdit ); |
|
| 751 | + if (ctype_digit((string)$itemToEdit)) { |
|
| 752 | + $editedItem = self::get_unit_group((int)$itemToEdit); |
|
| 753 | 753 | } else { |
| 754 | 754 | $editedItem = ''; |
| 755 | 755 | } |
| 756 | 756 | |
| 757 | 757 | $the_form_content_hidden = $the_form_general_content = $the_form_option_content = ''; |
| 758 | - foreach($dbFieldList as $input_key => $input_def){ |
|
| 758 | + foreach ($dbFieldList as $input_key => $input_def) { |
|
| 759 | 759 | $pageAction = isset($_REQUEST[WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . '_action']) ? wpshop_tools::varSanitizer($_REQUEST[WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . '_action']) : ''; |
| 760 | 760 | $requestFormValue = isset($_REQUEST[self::currentPageCode][$input_def['name']]) ? wpshop_tools::varSanitizer($_REQUEST[self::currentPageCode][$input_def['name']]) : ''; |
| 761 | 761 | $currentFieldValue = $input_def['value']; |
| 762 | - if(is_object($editedItem)){ |
|
| 762 | + if (is_object($editedItem)) { |
|
| 763 | 763 | $currentFieldValue = $editedItem->{$input_def['name']}; |
| 764 | 764 | } |
| 765 | - elseif(($pageAction != '') && ($requestFormValue != '')){ |
|
| 765 | + elseif (($pageAction != '') && ($requestFormValue != '')) { |
|
| 766 | 766 | $currentFieldValue = $requestFormValue; |
| 767 | 767 | } |
| 768 | 768 | |
@@ -771,9 +771,9 @@ discard block |
||
| 771 | 771 | $input_def['value'] = __(str_replace("\\", "", $input_def['value']), 'wpshop'); |
| 772 | 772 | $the_input = wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP); |
| 773 | 773 | |
| 774 | - if($input_def['type'] != 'hidden'){ |
|
| 774 | + if ($input_def['type'] != 'hidden') { |
|
| 775 | 775 | $label = 'for="' . $input_def['name'] . '"'; |
| 776 | - if(($input_def['type'] == 'radio') || ($input_def['type'] == 'checkbox')){ |
|
| 776 | + if (($input_def['type'] == 'radio') || ($input_def['type'] == 'checkbox')) { |
|
| 777 | 777 | $label = ''; |
| 778 | 778 | } |
| 779 | 779 | $input = ' |
@@ -785,30 +785,30 @@ discard block |
||
| 785 | 785 | ' . $the_input . ' |
| 786 | 786 | </div> |
| 787 | 787 | </div>'; |
| 788 | - if(substr($input_def['name'], 0, 3) == 'is_'){ |
|
| 788 | + if (substr($input_def['name'], 0, 3) == 'is_') { |
|
| 789 | 789 | $the_form_option_content .= $input; |
| 790 | 790 | } |
| 791 | - else{ |
|
| 791 | + else { |
|
| 792 | 792 | $the_form_general_content .= $input; |
| 793 | 793 | } |
| 794 | 794 | } |
| 795 | - else{ |
|
| 795 | + else { |
|
| 796 | 796 | $the_form_content_hidden .= ' |
| 797 | 797 | ' . $the_input; |
| 798 | 798 | } |
| 799 | 799 | } |
| 800 | 800 | |
| 801 | 801 | $the_form = '<form name="' . WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . '_form" id="' . WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . '_form" method="post" action="' . admin_url('admin-ajax.php') . '" >'; |
| 802 | - if( ctype_digit( (string) $itemToEdit ) ) { |
|
| 802 | + if (ctype_digit((string)$itemToEdit)) { |
|
| 803 | 803 | $the_form .= wpshop_form::form_input('action', 'action', 'wps_attribute_group_unit_update', 'hidden'); |
| 804 | - $the_form .= wp_nonce_field( 'update_attribute_unit_group', '_wpnonce' ); |
|
| 804 | + $the_form .= wp_nonce_field('update_attribute_unit_group', '_wpnonce'); |
|
| 805 | 805 | } else { |
| 806 | 806 | $the_form .= wpshop_form::form_input('action', 'action', 'wps_attribute_group_unit_new', 'hidden'); |
| 807 | - $the_form .= wp_nonce_field( 'save_new_attribute_unit_group', '_wpnonce' ); |
|
| 807 | + $the_form .= wp_nonce_field('save_new_attribute_unit_group', '_wpnonce'); |
|
| 808 | 808 | } |
| 809 | - $the_form .= wpshop_form::form_input(self::currentPageCode . '_form_has_modification', self::currentPageCode . '_form_has_modification', 'no' , 'hidden'); |
|
| 809 | + $the_form .= wpshop_form::form_input(self::currentPageCode . '_form_has_modification', self::currentPageCode . '_form_has_modification', 'no', 'hidden'); |
|
| 810 | 810 | $the_form .= $the_form_content_hidden . $the_form_general_content; |
| 811 | - $the_form .= '<input type="button" value="' . __('Retour', 'wpshop') . '" class="button-primary alignright" name="cancel_unit_group_edition" id="cancel_unit_group_edition" data-nonce="' . wp_create_nonce( 'load_attribute_unit_groups' ) . '"/> |
|
| 811 | + $the_form .= '<input type="button" value="' . __('Retour', 'wpshop') . '" class="button-primary alignright" name="cancel_unit_group_edition" id="cancel_unit_group_edition" data-nonce="' . wp_create_nonce('load_attribute_unit_groups') . '"/> |
|
| 812 | 812 | <input type="submit" value="' . __('Save', 'wpshop') . '" class="button-primary alignright" name="save_new_unit_group" id="save_new_unit_group" /> |
| 813 | 813 | </form> |
| 814 | 814 | <script type="text/javascript" > |
@@ -836,11 +836,11 @@ discard block |
||
| 836 | 836 | |
| 837 | 837 | /* Default currecy for the entire shop */ |
| 838 | 838 | public static function wpshop_shop_currency_list_field() { |
| 839 | - if( is_null( self::$currencies_cache ) ) { |
|
| 839 | + if (is_null(self::$currencies_cache)) { |
|
| 840 | 840 | $currency_group = get_option('wpshop_shop_currency_group'); |
| 841 | - if( !empty ( $currency_group ) ) { |
|
| 841 | + if (!empty ($currency_group)) { |
|
| 842 | 842 | global $wpdb; |
| 843 | - $query = $wpdb->prepare('SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE_UNIT. ' WHERE group_id = %d', $currency_group); |
|
| 843 | + $query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE group_id = %d', $currency_group); |
|
| 844 | 844 | self::$currencies_cache = $wpdb->get_results($query); |
| 845 | 845 | } else { |
| 846 | 846 | self::$currencies_cache = ''; |
@@ -850,17 +850,17 @@ discard block |
||
| 850 | 850 | $current_currency = get_option('wpshop_shop_default_currency'); |
| 851 | 851 | |
| 852 | 852 | $currencies_options = ''; |
| 853 | - if ( !empty (self::$currencies_cache) ) { |
|
| 854 | - foreach ( self::$currencies_cache as $currency) { |
|
| 855 | - $currencies_options .= '<option value="'.$currency->id.'"'.(($currency->id == $current_currency) ? ' selected="selected"' : null).'>'.$currency->name.' ('.$currency->unit.')</option>'; |
|
| 853 | + if (!empty (self::$currencies_cache)) { |
|
| 854 | + foreach (self::$currencies_cache as $currency) { |
|
| 855 | + $currencies_options .= '<option value="' . $currency->id . '"' . (($currency->id == $current_currency) ? ' selected="selected"' : null) . '>' . $currency->name . ' (' . $currency->unit . ')</option>'; |
|
| 856 | 856 | } |
| 857 | 857 | } |
| 858 | 858 | else { |
| 859 | - foreach($wpshop_shop_currencies as $k => $v) { |
|
| 860 | - $currencies_options .= '<option value="'.$k.'"'.(($k==$current_currency) ? ' selected="selected"' : null).'>'.$k.' ('.$v.')</option>'; |
|
| 859 | + foreach ($wpshop_shop_currencies as $k => $v) { |
|
| 860 | + $currencies_options .= '<option value="' . $k . '"' . (($k == $current_currency) ? ' selected="selected"' : null) . '>' . $k . ' (' . $v . ')</option>'; |
|
| 861 | 861 | } |
| 862 | 862 | } |
| 863 | - return '<select name="wpshop_shop_default_currency" class="wpshop_currency_field" >'.$currencies_options.'</select>'; |
|
| 863 | + return '<select name="wpshop_shop_default_currency" class="wpshop_currency_field" >' . $currencies_options . '</select>'; |
|
| 864 | 864 | } |
| 865 | 865 | |
| 866 | 866 | /** |
@@ -873,7 +873,7 @@ discard block |
||
| 873 | 873 | global $wpdb; |
| 874 | 874 | |
| 875 | 875 | /** Get the _unit_group_id and _default_unit */ |
| 876 | - return $wpdb->get_row( $wpdb->prepare( 'SELECT _unit_group_id, _default_unit FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE code=%s', array( $attribute_code ) ) ); |
|
| 876 | + return $wpdb->get_row($wpdb->prepare('SELECT _unit_group_id, _default_unit FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE code=%s', array($attribute_code))); |
|
| 877 | 877 | } |
| 878 | 878 | |
| 879 | 879 | /** |
@@ -885,15 +885,15 @@ discard block |
||
| 885 | 885 | * @return stdClass Object [_unit_group_id], [_default_unit] |
| 886 | 886 | */ |
| 887 | 887 | public static function get_the_attribute_unit_by_code_for_product($product_id, $attribute_code) { |
| 888 | - $unit = self::get_default_unit_attribute( $attribute_code ); |
|
| 888 | + $unit = self::get_default_unit_attribute($attribute_code); |
|
| 889 | 889 | |
| 890 | - if(empty($unit)) |
|
| 890 | + if (empty($unit)) |
|
| 891 | 891 | return null; |
| 892 | 892 | |
| 893 | 893 | $post_meta = get_post_meta($product_id, '_wpshop_product_metadata', true); |
| 894 | 894 | |
| 895 | 895 | /** Si on trouve une unité */ |
| 896 | - if(!empty($post_meta) && !empty($post_meta['unit']) && !empty($post_meta['unit'][$attribute_code])) |
|
| 896 | + if (!empty($post_meta) && !empty($post_meta['unit']) && !empty($post_meta['unit'][$attribute_code])) |
|
| 897 | 897 | $unit->_default_unit = $post_meta['unit'][$attribute_code]; |
| 898 | 898 | |
| 899 | 899 | return $unit; |
@@ -908,7 +908,7 @@ discard block |
||
| 908 | 908 | public static function the_attribute_unit_by_code_for_product($product_id, $attribute_code) { |
| 909 | 909 | $unit = self::get_the_attribute_unit_by_code_for_product($product_id, $attribute_code); |
| 910 | 910 | |
| 911 | - if(empty($unit)) |
|
| 911 | + if (empty($unit)) |
|
| 912 | 912 | return null; |
| 913 | 913 | |
| 914 | 914 | echo self::get_the_subname_unit($unit->_unit_group_id, $unit->_default_unit); |
@@ -925,10 +925,10 @@ discard block |
||
| 925 | 925 | global $wpdb; |
| 926 | 926 | |
| 927 | 927 | /** Si pas d'unité ou de groupe, null */ |
| 928 | - if(0 === $unit_id || 0 === $group_id) |
|
| 928 | + if (0 === $unit_id || 0 === $group_id) |
|
| 929 | 929 | return null; |
| 930 | 930 | |
| 931 | - return $wpdb->get_var( $wpdb->prepare( 'SELECT name FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE group_id=%d AND id=%d', array( $group_id, $unit_id ) ) ); |
|
| 931 | + return $wpdb->get_var($wpdb->prepare('SELECT name FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE group_id=%d AND id=%d', array($group_id, $unit_id))); |
|
| 932 | 932 | } |
| 933 | 933 | |
| 934 | 934 | /** |
@@ -942,9 +942,9 @@ discard block |
||
| 942 | 942 | global $wpdb; |
| 943 | 943 | |
| 944 | 944 | /** Si pas d'unité ou de groupe, null */ |
| 945 | - if(0 === $unit_id || 0 === $group_id) |
|
| 945 | + if (0 === $unit_id || 0 === $group_id) |
|
| 946 | 946 | return null; |
| 947 | 947 | |
| 948 | - return $wpdb->get_var( $wpdb->prepare( 'SELECT unit FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE group_id=%d AND id=%d', array( $group_id, $unit_id ) ) ); |
|
| 948 | + return $wpdb->get_var($wpdb->prepare('SELECT unit FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE group_id=%d AND id=%d', array($group_id, $unit_id))); |
|
| 949 | 949 | } |
| 950 | 950 | } |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | |
| 3 | 5 | /* Check if file is include. No direct access possible with file url */ |
| 4 | 6 | if ( !defined( 'WPSHOP_VERSION' ) ) { |
@@ -125,13 +127,11 @@ discard block |
||
| 125 | 127 | { |
| 126 | 128 | $editedItem = self::getElement($objectInEdition); |
| 127 | 129 | $title = sprintf(__(self::pageEditingTitle, 'wpshop'), str_replace("\\", "", $editedItem->frontend_label) . ' (' . $editedItem->code . ')'); |
| 128 | - } |
|
| 129 | - elseif($action == 'add') |
|
| 130 | + } elseif($action == 'add') |
|
| 130 | 131 | { |
| 131 | 132 | $title = __(self::pageAddingTitle, 'wpshop'); |
| 132 | 133 | } |
| 133 | - } |
|
| 134 | - elseif((self::getEditionSlug() != self::getListingSlug()) && (sanitize_text_field($page) == self::getEditionSlug())) |
|
| 134 | + } elseif((self::getEditionSlug() != self::getListingSlug()) && (sanitize_text_field($page) == self::getEditionSlug())) |
|
| 135 | 135 | { |
| 136 | 136 | $title = __(self::pageAddingTitle, 'wpshop'); |
| 137 | 137 | } |
@@ -156,8 +156,7 @@ discard block |
||
| 156 | 156 | { |
| 157 | 157 | $editedElement = self::getElement($saveditem); |
| 158 | 158 | $pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully saved', 'wpshop'), '<span class="bold" >' . $editedElement->code . '</span>'); |
| 159 | - } |
|
| 160 | - elseif(($action != '') && ($action == 'deleteok') && ($saveditem > 0)) |
|
| 159 | + } elseif(($action != '') && ($action == 'deleteok') && ($saveditem > 0)) |
|
| 161 | 160 | { |
| 162 | 161 | $editedElement = self::getElement($saveditem, "'deleted'"); |
| 163 | 162 | $pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully deleted', 'wpshop'), '<span class="bold" >' . $editedElement->code . '</span>'); |
@@ -179,32 +178,27 @@ discard block |
||
| 179 | 178 | if(current_user_can('wpshop_delete_attributes')) |
| 180 | 179 | { |
| 181 | 180 | $attribute_group_parameter['status'] = 'deleted'; |
| 182 | - } |
|
| 183 | - else |
|
| 181 | + } else |
|
| 184 | 182 | { |
| 185 | 183 | $actionResult = 'userNotAllowedForActionDelete'; |
| 186 | 184 | } |
| 187 | 185 | } |
| 188 | 186 | $actionResult = wpshop_database::update($attribute_group_parameter, $id, self::getDbTable()); |
| 189 | - } |
|
| 190 | - else |
|
| 187 | + } else |
|
| 191 | 188 | { |
| 192 | 189 | $actionResult = 'userNotAllowedForActionEdit'; |
| 193 | 190 | } |
| 194 | - } |
|
| 195 | - elseif(($pageAction != '') && (($pageAction == 'delete'))){ |
|
| 191 | + } elseif(($pageAction != '') && (($pageAction == 'delete'))){ |
|
| 196 | 192 | if(current_user_can('wpshop_delete_attributes')) |
| 197 | 193 | { |
| 198 | 194 | $attribute_group_parameter['last_update_date'] = date('Y-m-d H:i:s'); |
| 199 | 195 | $attribute_group_parameter['status'] = 'deleted'; |
| 200 | 196 | $actionResult = wpshop_database::update($attribute_group_parameter, $id, self::getDbTable()); |
| 201 | - } |
|
| 202 | - else |
|
| 197 | + } else |
|
| 203 | 198 | { |
| 204 | 199 | $actionResult = 'userNotAllowedForActionDelete'; |
| 205 | 200 | } |
| 206 | - } |
|
| 207 | - elseif(($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))){ |
|
| 201 | + } elseif(($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))){ |
|
| 208 | 202 | if(current_user_can('wpshop_add_attributes')){ |
| 209 | 203 | $attribute_group_parameter['creation_date'] = date('Y-m-d H:i:s'); |
| 210 | 204 | if(trim($attribute_group_parameter['code']) == ''){ |
@@ -217,8 +211,7 @@ discard block |
||
| 217 | 211 | } |
| 218 | 212 | $actionResult = wpshop_database::save($attribute_group_parameter, self::getDbTable()); |
| 219 | 213 | $id = $wpdb->insert_id; |
| 220 | - } |
|
| 221 | - else{ |
|
| 214 | + } else{ |
|
| 222 | 215 | $actionResult = 'userNotAllowedForActionAdd'; |
| 223 | 216 | } |
| 224 | 217 | } |
@@ -236,8 +229,7 @@ discard block |
||
| 236 | 229 | { |
| 237 | 230 | $pageMessage .= '<br/>' . $wpdb->last_error; |
| 238 | 231 | } |
| 239 | - } |
|
| 240 | - elseif(($actionResult == 'done') || ($actionResult == 'nothingToUpdate')) |
|
| 232 | + } elseif(($actionResult == 'done') || ($actionResult == 'nothingToUpdate')) |
|
| 241 | 233 | {/* CHANGE HERE FOR SPECIFIC CASE */ |
| 242 | 234 | /*****************************************************************************************************************/ |
| 243 | 235 | /************************* CHANGE FOR SPECIFIC ACTION FOR CURRENT ELEMENT ******************/ |
@@ -250,17 +242,14 @@ discard block |
||
| 250 | 242 | if(($pageAction == 'edit') || ($pageAction == 'save')) |
| 251 | 243 | { |
| 252 | 244 | wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=saveok&saveditem=" . $id)); |
| 253 | - } |
|
| 254 | - elseif($pageAction == 'add') |
|
| 245 | + } elseif($pageAction == 'add') |
|
| 255 | 246 | { |
| 256 | 247 | wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=edit&id=" . $id)); |
| 257 | - } |
|
| 258 | - elseif($pageAction == 'delete') |
|
| 248 | + } elseif($pageAction == 'delete') |
|
| 259 | 249 | { |
| 260 | 250 | wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=deleteok&saveditem=" . $id)); |
| 261 | 251 | } |
| 262 | - } |
|
| 263 | - elseif(($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete')) |
|
| 252 | + } elseif(($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete')) |
|
| 264 | 253 | { |
| 265 | 254 | $pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . __('You are not allowed to do this action', 'wpshop'); |
| 266 | 255 | } |
@@ -309,8 +298,7 @@ discard block |
||
| 309 | 298 | $editAction = admin_url('admin.php?page=' . $attributeSlugUrl . '&action=edit&id=' . $element->id); |
| 310 | 299 | $subRowActions .= ' |
| 311 | 300 | <a href="#" id="edit_attribute_unit_' . $element->id . '" class="edit_attribute_unit" data-nonce="' . wp_create_nonce( 'edit_attribute_unit_' . $element->id ) . '" >' . __('Edit', 'wpshop') . '</a>'; |
| 312 | - } |
|
| 313 | - elseif(current_user_can('wpshop_view_attributes_unit')) |
|
| 301 | + } elseif(current_user_can('wpshop_view_attributes_unit')) |
|
| 314 | 302 | { |
| 315 | 303 | $editAction = admin_url('admin.php?page=' . $attributeSlugUrl . '&action=edit&id=' . $element->id); |
| 316 | 304 | } |
@@ -336,8 +324,7 @@ discard block |
||
| 336 | 324 | |
| 337 | 325 | $line++; |
| 338 | 326 | } |
| 339 | - } |
|
| 340 | - else{ |
|
| 327 | + } else{ |
|
| 341 | 328 | unset($tableRowValue); |
| 342 | 329 | $tableRowValue[] = array('class' => self::currentPageCode . '_label_cell', 'value' => __('No element to ouput here', 'wpshop')); |
| 343 | 330 | $tableRowValue[] = array('class' => self::currentPageCode . '_name_cell', 'value' => ''); |
@@ -418,8 +405,7 @@ discard block |
||
| 418 | 405 | $currentFieldValue = $input_def['value']; |
| 419 | 406 | if(is_object($editedItem)){ |
| 420 | 407 | $currentFieldValue = $editedItem->{$input_def['name']}; |
| 421 | - } |
|
| 422 | - elseif(($pageAction != '') && ($requestFormValue != '')){ |
|
| 408 | + } elseif(($pageAction != '') && ($requestFormValue != '')){ |
|
| 423 | 409 | $currentFieldValue = $requestFormValue; |
| 424 | 410 | } |
| 425 | 411 | |
@@ -451,8 +437,7 @@ discard block |
||
| 451 | 437 | </div>'; |
| 452 | 438 | |
| 453 | 439 | |
| 454 | - } |
|
| 455 | - else{ |
|
| 440 | + } else{ |
|
| 456 | 441 | $the_form_content_hidden .= ' |
| 457 | 442 | ' . $the_input; |
| 458 | 443 | } |
@@ -508,8 +493,7 @@ discard block |
||
| 508 | 493 | { |
| 509 | 494 | $currentPageButton .= '<input type="button" class="button-primary" id="add" name="add" value="' . __('Add', 'wpshop') . '" />'; |
| 510 | 495 | } |
| 511 | - } |
|
| 512 | - elseif(current_user_can('wpshop_edit_attributes')) |
|
| 496 | + } elseif(current_user_can('wpshop_edit_attributes')) |
|
| 513 | 497 | { |
| 514 | 498 | $currentPageButton .= '<input type="button" class="button-primary" id="save" name="save" value="' . __('Save', 'wpshop') . '" /><input type="button" class="button-primary" id="saveandcontinue" name="saveandcontinue" value="' . __('Save and continue edit', 'wpshop') . '" />'; |
| 515 | 499 | } |
@@ -554,8 +538,7 @@ discard block |
||
| 554 | 538 | /* Get the query result regarding on the function parameters. If there must be only one result or a collection */ |
| 555 | 539 | if($element_id == ''){ |
| 556 | 540 | $element_list = $wpdb->get_results($query); |
| 557 | - } |
|
| 558 | - else{ |
|
| 541 | + } else{ |
|
| 559 | 542 | $element_list = $wpdb->get_row($query); |
| 560 | 543 | } |
| 561 | 544 | |
@@ -615,10 +598,11 @@ discard block |
||
| 615 | 598 | ); |
| 616 | 599 | |
| 617 | 600 | /* Get the query result regarding on the function parameters. If there must be only one result or a collection */ |
| 618 | - if($element_id == '') |
|
| 619 | - $element_list = $wpdb->get_results($query); |
|
| 620 | - else |
|
| 621 | - $element_list = $wpdb->get_row($query); |
|
| 601 | + if($element_id == '') { |
|
| 602 | + $element_list = $wpdb->get_results($query); |
|
| 603 | + } else { |
|
| 604 | + $element_list = $wpdb->get_row($query); |
|
| 605 | + } |
|
| 622 | 606 | |
| 623 | 607 | return $element_list; |
| 624 | 608 | |
@@ -662,8 +646,7 @@ discard block |
||
| 662 | 646 | $editAction = admin_url('admin.php?page=' . $attributeSlugUrl . '&action=edit&id=' . $element->id); |
| 663 | 647 | $subRowActions .= ' |
| 664 | 648 | <a href="#" id="edit_attribute_unit_group_' . $element->id . '" class="edit_attribute_unit_group" data-nonce="' . wp_create_nonce( 'edit_attribute_unit_group_' . $element->id ) . '" >' . __('Edit', 'wpshop') . '</a>'; |
| 665 | - } |
|
| 666 | - elseif(current_user_can('wpshop_view_attributes_unit_group')) |
|
| 649 | + } elseif(current_user_can('wpshop_view_attributes_unit_group')) |
|
| 667 | 650 | { |
| 668 | 651 | $editAction = admin_url('admin.php?page=' . $attributeSlugUrl . '&action=edit&id=' . $element->id); |
| 669 | 652 | } |
@@ -687,8 +670,7 @@ discard block |
||
| 687 | 670 | |
| 688 | 671 | $line++; |
| 689 | 672 | } |
| 690 | - } |
|
| 691 | - else{ |
|
| 673 | + } else{ |
|
| 692 | 674 | unset($tableRowValue); |
| 693 | 675 | $tableRowValue[] = array('class' => self::currentPageCode . '_label_cell', 'value' => __('No element to ouput here', 'wpshop')); |
| 694 | 676 | $tableRows[] = $tableRowValue; |
@@ -761,8 +743,7 @@ discard block |
||
| 761 | 743 | $currentFieldValue = $input_def['value']; |
| 762 | 744 | if(is_object($editedItem)){ |
| 763 | 745 | $currentFieldValue = $editedItem->{$input_def['name']}; |
| 764 | - } |
|
| 765 | - elseif(($pageAction != '') && ($requestFormValue != '')){ |
|
| 746 | + } elseif(($pageAction != '') && ($requestFormValue != '')){ |
|
| 766 | 747 | $currentFieldValue = $requestFormValue; |
| 767 | 748 | } |
| 768 | 749 | |
@@ -787,12 +768,10 @@ discard block |
||
| 787 | 768 | </div>'; |
| 788 | 769 | if(substr($input_def['name'], 0, 3) == 'is_'){ |
| 789 | 770 | $the_form_option_content .= $input; |
| 790 | - } |
|
| 791 | - else{ |
|
| 771 | + } else{ |
|
| 792 | 772 | $the_form_general_content .= $input; |
| 793 | 773 | } |
| 794 | - } |
|
| 795 | - else{ |
|
| 774 | + } else{ |
|
| 796 | 775 | $the_form_content_hidden .= ' |
| 797 | 776 | ' . $the_input; |
| 798 | 777 | } |
@@ -854,8 +833,7 @@ discard block |
||
| 854 | 833 | foreach ( self::$currencies_cache as $currency) { |
| 855 | 834 | $currencies_options .= '<option value="'.$currency->id.'"'.(($currency->id == $current_currency) ? ' selected="selected"' : null).'>'.$currency->name.' ('.$currency->unit.')</option>'; |
| 856 | 835 | } |
| 857 | - } |
|
| 858 | - else { |
|
| 836 | + } else { |
|
| 859 | 837 | foreach($wpshop_shop_currencies as $k => $v) { |
| 860 | 838 | $currencies_options .= '<option value="'.$k.'"'.(($k==$current_currency) ? ' selected="selected"' : null).'>'.$k.' ('.$v.')</option>'; |
| 861 | 839 | } |
@@ -887,14 +865,16 @@ discard block |
||
| 887 | 865 | public static function get_the_attribute_unit_by_code_for_product($product_id, $attribute_code) { |
| 888 | 866 | $unit = self::get_default_unit_attribute( $attribute_code ); |
| 889 | 867 | |
| 890 | - if(empty($unit)) |
|
| 891 | - return null; |
|
| 868 | + if(empty($unit)) { |
|
| 869 | + return null; |
|
| 870 | + } |
|
| 892 | 871 | |
| 893 | 872 | $post_meta = get_post_meta($product_id, '_wpshop_product_metadata', true); |
| 894 | 873 | |
| 895 | 874 | /** Si on trouve une unité */ |
| 896 | - if(!empty($post_meta) && !empty($post_meta['unit']) && !empty($post_meta['unit'][$attribute_code])) |
|
| 897 | - $unit->_default_unit = $post_meta['unit'][$attribute_code]; |
|
| 875 | + if(!empty($post_meta) && !empty($post_meta['unit']) && !empty($post_meta['unit'][$attribute_code])) { |
|
| 876 | + $unit->_default_unit = $post_meta['unit'][$attribute_code]; |
|
| 877 | + } |
|
| 898 | 878 | |
| 899 | 879 | return $unit; |
| 900 | 880 | } |
@@ -908,8 +888,9 @@ discard block |
||
| 908 | 888 | public static function the_attribute_unit_by_code_for_product($product_id, $attribute_code) { |
| 909 | 889 | $unit = self::get_the_attribute_unit_by_code_for_product($product_id, $attribute_code); |
| 910 | 890 | |
| 911 | - if(empty($unit)) |
|
| 912 | - return null; |
|
| 891 | + if(empty($unit)) { |
|
| 892 | + return null; |
|
| 893 | + } |
|
| 913 | 894 | |
| 914 | 895 | echo self::get_the_subname_unit($unit->_unit_group_id, $unit->_default_unit); |
| 915 | 896 | } |
@@ -925,8 +906,9 @@ discard block |
||
| 925 | 906 | global $wpdb; |
| 926 | 907 | |
| 927 | 908 | /** Si pas d'unité ou de groupe, null */ |
| 928 | - if(0 === $unit_id || 0 === $group_id) |
|
| 929 | - return null; |
|
| 909 | + if(0 === $unit_id || 0 === $group_id) { |
|
| 910 | + return null; |
|
| 911 | + } |
|
| 930 | 912 | |
| 931 | 913 | return $wpdb->get_var( $wpdb->prepare( 'SELECT name FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE group_id=%d AND id=%d', array( $group_id, $unit_id ) ) ); |
| 932 | 914 | } |
@@ -942,8 +924,9 @@ discard block |
||
| 942 | 924 | global $wpdb; |
| 943 | 925 | |
| 944 | 926 | /** Si pas d'unité ou de groupe, null */ |
| 945 | - if(0 === $unit_id || 0 === $group_id) |
|
| 946 | - return null; |
|
| 927 | + if(0 === $unit_id || 0 === $group_id) { |
|
| 928 | + return null; |
|
| 929 | + } |
|
| 947 | 930 | |
| 948 | 931 | return $wpdb->get_var( $wpdb->prepare( 'SELECT unit FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE group_id=%d AND id=%d', array( $group_id, $unit_id ) ) ); |
| 949 | 932 | } |
@@ -88,7 +88,6 @@ discard block |
||
| 88 | 88 | /** |
| 89 | 89 | * The metabox content for entity type support section in entity edition page |
| 90 | 90 | * |
| 91 | - * @param object $post The entity type being edited |
|
| 92 | 91 | */ |
| 93 | 92 | public static function wpshop_entity_support_section( $entity ) { |
| 94 | 93 | $output = ''; |
@@ -657,7 +656,7 @@ discard block |
||
| 657 | 656 | /** |
| 658 | 657 | * Define custom columns content display in post_type page for wpshop entities |
| 659 | 658 | * |
| 660 | - * @param string $columns The default column for the post_type given in second parameter |
|
| 659 | + * @param string $column The default column for the post_type given in second parameter |
|
| 661 | 660 | * @param integer $post_id The current post identifier to get information for display |
| 662 | 661 | */ |
| 663 | 662 | public static function custom_columns_content($column, $post_id) { |
@@ -53,11 +53,11 @@ discard block |
||
| 53 | 53 | 'exclude_from_search' => true, |
| 54 | 54 | 'capabilities' => array( |
| 55 | 55 | 'edit_post' => 'wpshop_view_dashboard', |
| 56 | - 'edit_posts' => 'wpshop_view_dashboard', |
|
| 57 | - 'edit_others_posts' => 'wpshop_view_dashboard', |
|
| 58 | - 'publish_posts' => 'wpshop_view_dashboard', |
|
| 59 | - 'read_post' => 'wpshop_view_dashboard', |
|
| 60 | - 'read_private_posts' => 'wpshop_view_dashboard', |
|
| 56 | + 'edit_posts' => 'wpshop_view_dashboard', |
|
| 57 | + 'edit_others_posts' => 'wpshop_view_dashboard', |
|
| 58 | + 'publish_posts' => 'wpshop_view_dashboard', |
|
| 59 | + 'read_post' => 'wpshop_view_dashboard', |
|
| 60 | + 'read_private_posts' => 'wpshop_view_dashboard', |
|
| 61 | 61 | 'delete_posts' => 'delete_product' |
| 62 | 62 | ), |
| 63 | 63 | )); |
@@ -421,7 +421,7 @@ discard block |
||
| 421 | 421 | * Save informations for current entity |
| 422 | 422 | */ |
| 423 | 423 | public static function save_entities_custom_informations( $post_id ) { |
| 424 | - global $wpdb, $wpshop_account; |
|
| 424 | + global $wpdb, $wpshop_account; |
|
| 425 | 425 | |
| 426 | 426 | $edit_other_thing = !empty( $_POST['edit_other_thing'] ) ? (int) $_POST['edit_other_thing'] : 0; |
| 427 | 427 | |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | /** |
| 3 | 5 | * Define utilities to manage entities |
| 4 | 6 | * |
@@ -215,8 +217,7 @@ discard block |
||
| 215 | 217 | $current_entity_params = get_post_meta($entity->ID, '_wpshop_entity_params', true); |
| 216 | 218 | if ( !empty($current_entity_params['display_admin_menu']) ) { |
| 217 | 219 | $show_in_menu = WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES; |
| 218 | - } |
|
| 219 | - else { |
|
| 220 | + } else { |
|
| 220 | 221 | $show_in_menu = false; |
| 221 | 222 | } |
| 222 | 223 | $post_type_params = array( |
@@ -330,15 +331,15 @@ discard block |
||
| 330 | 331 | foreach ($currentTabContent['box'] as $boxIdentifier => $boxTitle) { |
| 331 | 332 | if (!empty($currentTabContent['box'][$boxIdentifier.'_backend_display_type']) &&( $currentTabContent['box'][$boxIdentifier.'_backend_display_type']=='movable-tab')) { |
| 332 | 333 | add_meta_box($post->post_type . '_' . $boxIdentifier, __($boxTitle, 'wpshop'), array('wpshop_entities', 'meta_box_content'), $post->post_type, 'normal', 'default', array('currentTabContent' => $currentTabContent['boxContent'][$boxIdentifier])); |
| 334 | + } else { |
|
| 335 | + $fixed_box_exist = true; |
|
| 333 | 336 | } |
| 334 | - else $fixed_box_exist = true; |
|
| 335 | 337 | } |
| 336 | 338 | } |
| 337 | 339 | if ($fixed_box_exist && $post->post_type != WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ) { |
| 338 | 340 | add_meta_box($post->post_type . '_fixed_tab', __('Informations', 'wpshop'), array('wpshop_entities', 'meta_box_content_datas'), $post->post_type, 'normal', 'high', array('currentTabContent' => $currentTabContent)); |
| 339 | 341 | } |
| 340 | - } |
|
| 341 | - elseif (count($attribute_set_list) > 1) { |
|
| 342 | + } elseif (count($attribute_set_list) > 1) { |
|
| 342 | 343 | $input_def['id'] = $post->post_type.'_attribute_set_id'; |
| 343 | 344 | $input_def['name'] = $post->post_type.'_attribute_set_id'; |
| 344 | 345 | $input_def['value'] = ''; |
@@ -490,8 +491,7 @@ discard block |
||
| 490 | 491 | if( !empty( $current_id ) ) { |
| 491 | 492 | update_post_meta ($post_id, '_wpshop_attached_address', $current_id); |
| 492 | 493 | } |
| 493 | - } |
|
| 494 | - else { |
|
| 494 | + } else { |
|
| 495 | 495 | $current_id = array(); |
| 496 | 496 | |
| 497 | 497 | $address_type = !empty($_REQUEST['address_type']) ? (array) $_REQUEST['address_type'] : null; |
@@ -608,8 +608,7 @@ discard block |
||
| 608 | 608 | $new_element_link = '<a class="wpshop_cls wpshop_duplicate_entity_element_link" href="' . admin_url('post.php?post=' . $last_post . '&action=edit') . '" >' . __('Go on the new element edit page', 'wpshop') . '</a>'; |
| 609 | 609 | if ( $meta_creation ) { |
| 610 | 610 | return array('true', '<br/>' . $new_element_link, $last_post ); |
| 611 | - } |
|
| 612 | - else { |
|
| 611 | + } else { |
|
| 613 | 612 | return array('true', '<br/>' . __('Some errors occured while duplicating meta information, but element has been created.', 'wpshop') . ' ' . $new_element_link); |
| 614 | 613 | } |
| 615 | 614 | } |
@@ -675,18 +674,21 @@ discard block |
||
| 675 | 674 | $column_content = get_the_post_thumbnail( $post_id, 'thumbnail'); |
| 676 | 675 | break; |
| 677 | 676 | case "product_stock": |
| 678 | - if( !empty($product['product_stock']) ) |
|
| 679 | - $column_content = (int)$product['product_stock'].' '.__('unit(s)','wpshop'); |
|
| 677 | + if( !empty($product['product_stock']) ) { |
|
| 678 | + $column_content = (int)$product['product_stock'].' '.__('unit(s)','wpshop'); |
|
| 679 | + } |
|
| 680 | 680 | break; |
| 681 | 681 | |
| 682 | 682 | case "product_price": |
| 683 | - if( !empty($product['product_price']) ) |
|
| 684 | - $column_content = wpshop_prices::get_product_price( $product, 'price_display', 'complete_sheet'); |
|
| 683 | + if( !empty($product['product_price']) ) { |
|
| 684 | + $column_content = wpshop_prices::get_product_price( $product, 'price_display', 'complete_sheet'); |
|
| 685 | + } |
|
| 685 | 686 | break; |
| 686 | 687 | |
| 687 | 688 | case "tx_tva": |
| 688 | - if( !empty($product['product_price']) ) |
|
| 689 | - $column_content = number_format($product[$column],2,'.', ' ').' %'; |
|
| 689 | + if( !empty($product['product_price']) ) { |
|
| 690 | + $column_content = number_format($product[$column],2,'.', ' ').' %'; |
|
| 691 | + } |
|
| 690 | 692 | break; |
| 691 | 693 | default: |
| 692 | 694 | if ( !empty($product[$column]) ) { |
@@ -694,9 +696,9 @@ discard block |
||
| 694 | 696 | if ( in_array($column, $attribute_prices) ) { |
| 695 | 697 | $column_content = number_format($product[$column],2,'.', ' ').' '.wpshop_tools::wpshop_get_currency(); |
| 696 | 698 | |
| 699 | + } else { |
|
| 700 | + $column_content = $product[$column]; |
|
| 697 | 701 | } |
| 698 | - else |
|
| 699 | - $column_content = $product[$column]; |
|
| 700 | 702 | } |
| 701 | 703 | break; |
| 702 | 704 | } |
@@ -732,15 +734,13 @@ discard block |
||
| 732 | 734 | |
| 733 | 735 | if ( empty($shortcode_args['attribute_set_id']) || empty($shortcode_args['post_type']) ) { |
| 734 | 736 | $output = __('This form page is invalid because no set or type or content is defined. Please contact administrator with this error message', 'wpshop'); |
| 735 | - } |
|
| 736 | - else { |
|
| 737 | + } else { |
|
| 737 | 738 | $entity_identifier = wpshop_entities::get_entity_identifier_from_code($shortcode_args['post_type']); |
| 738 | 739 | $attribute_set_def = wpshop_attributes_set::getElement($shortcode_args['attribute_set_id'], "'valid'"); |
| 739 | 740 | |
| 740 | 741 | if ( empty($entity_identifier) || empty($attribute_set_def) || ($entity_identifier != $attribute_set_def->entity_id) ) { |
| 741 | 742 | $output = __('This form page is invalid because type and set are not linked. Please contact administrator with this error message', 'wpshop'); |
| 742 | - } |
|
| 743 | - else { |
|
| 743 | + } else { |
|
| 744 | 744 | /** Display wordpress fields */ |
| 745 | 745 | foreach ( explode(', ', $shortcode_args['fields']) as $field_name ) { |
| 746 | 746 | $label = ''; |
@@ -847,8 +847,7 @@ discard block |
||
| 847 | 847 | $tpl_component['DIALOG_BOX'] = ''; |
| 848 | 848 | $output = wpshop_display::display_template_element($template_part, $tpl_component, array(), 'wpshop'); |
| 849 | 849 | echo $output; |
| 850 | - } |
|
| 851 | - else { |
|
| 850 | + } else { |
|
| 852 | 851 | echo $wpshop_account->display_login_form(); |
| 853 | 852 | } |
| 854 | 853 | } |
@@ -887,8 +886,7 @@ discard block |
||
| 887 | 886 | /** Update the attribute set id for the current product */ |
| 888 | 887 | if ( !empty($extra_params['attribute_set_id']) ) { |
| 889 | 888 | $attribute_set_id = $extra_params['attribute_set_id']; |
| 890 | - } |
|
| 891 | - else { |
|
| 889 | + } else { |
|
| 892 | 890 | $query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE_SET . " WHERE status = %s AND entity_id = %d AND default_set = %s", 'valid', wpshop_entities::get_entity_identifier_from_code($entity_type) , 'yes'); |
| 893 | 891 | $attribute_set_id = $wpdb->get_var($query); |
| 894 | 892 | } |
@@ -941,12 +939,10 @@ discard block |
||
| 941 | 939 | if ( $field_name == 'post_name' ) { |
| 942 | 940 | $db_datas_definition[] = $identifier; |
| 943 | 941 | $db_field_definition[] = str_replace( 'post_', '', $field_name ); |
| 944 | - } |
|
| 945 | - else if ( $field_default_value == 'mandatory' ) { |
|
| 942 | + } else if ( $field_default_value == 'mandatory' ) { |
|
| 946 | 943 | $has_error = true; |
| 947 | 944 | $errors[] = $field_name; |
| 948 | - } |
|
| 949 | - else { |
|
| 945 | + } else { |
|
| 950 | 946 | $db_datas_definition[] = $field_default_value; |
| 951 | 947 | $db_field_definition[] = str_replace( 'post_', '', $field_name ); |
| 952 | 948 | } |
@@ -956,8 +952,7 @@ discard block |
||
| 956 | 952 | if ( $has_error ) { |
| 957 | 953 | $result = false; |
| 958 | 954 | $output = sprintf( __('You have to fill %s, they are mandatory for custom type creation', 'wpshop'), implode(',', $errors) ); |
| 959 | - } |
|
| 960 | - else { |
|
| 955 | + } else { |
|
| 961 | 956 | $custom_post_type_def = array(); |
| 962 | 957 | foreach ( $db_field_definition as $field_position => $field_name ) { |
| 963 | 958 | $custom_post_type_def['post_' . $field_name] = $db_datas_definition[$field_position]; |
@@ -999,8 +994,7 @@ discard block |
||
| 999 | 994 | $attributes_for_cpt = wpshop_entities::check_default_cpt_attributes( $identifier, $tpl_component, $has_error ); |
| 1000 | 995 | $has_error = $attributes_for_cpt[0]; |
| 1001 | 996 | $tpl_component['CUSTOM_POST_TYPE_DEFAULT_ATTRIBUTES'] = $attributes_for_cpt[1]; |
| 1002 | - } |
|
| 1003 | - else { |
|
| 997 | + } else { |
|
| 1004 | 998 | $tpl_component['CUSTOM_POST_TYPE_IDENTIFIER'] = '<img class="wpshop_tools_check_icon error" src="' . WPSHOP_MEDIAS_ICON_URL . 'informations/error_s.png" /> ' . $identifier; |
| 1005 | 999 | $tpl_component['TOOLS_CUSTOM_POST_TYPE_CONTAINER_CLASS'] = ' error'; |
| 1006 | 1000 | $template_part = 'wpshop_admin_tools_default_datas_check_main_element_content_error'; |
@@ -1038,8 +1032,7 @@ discard block |
||
| 1038 | 1032 | if ( $column_value == 'code' ) { |
| 1039 | 1033 | $code_column = $column_key; |
| 1040 | 1034 | // $available_columns[$column_value] = $column_key; |
| 1041 | - } |
|
| 1042 | - else if ( in_array( $column_value, array('frontend_label')/* $attribute_displayed_field */ ) ) { |
|
| 1035 | + } else if ( in_array( $column_value, array('frontend_label')/* $attribute_displayed_field */ ) ) { |
|
| 1043 | 1036 | $available_columns[$column_value] = $column_key; |
| 1044 | 1037 | } |
| 1045 | 1038 | } |
@@ -1055,8 +1048,7 @@ discard block |
||
| 1055 | 1048 | if ( in_array( $line_column, $available_columns ) ) { |
| 1056 | 1049 | if ( !empty($attribute) ) { |
| 1057 | 1050 | $attribute_ok .= $attribute->frontend_label . ', '; |
| 1058 | - } |
|
| 1059 | - else { |
|
| 1051 | + } else { |
|
| 1060 | 1052 | $attribute_not_ok .= $line_column_value . ', '; |
| 1061 | 1053 | $has_error = true; |
| 1062 | 1054 | } |
@@ -1127,8 +1119,7 @@ discard block |
||
| 1127 | 1119 | break; |
| 1128 | 1120 | } |
| 1129 | 1121 | $attribute_def[$column_name] = ( !empty($attribute_definition[$column_index]) ) ? $column_value : ''; |
| 1130 | - } |
|
| 1131 | - else { |
|
| 1122 | + } else { |
|
| 1132 | 1123 | switch ( $column_name ) { |
| 1133 | 1124 | case 'available_values': |
| 1134 | 1125 | $attribute_values = $attribute_definition[$column_index]; |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | /** |
| 3 | 3 | * Define utilities to manage entities |
| 4 | 4 | * |
@@ -11,8 +11,8 @@ discard block |
||
| 11 | 11 | /* |
| 12 | 12 | * Check if file is include. No direct access possible with file url |
| 13 | 13 | */ |
| 14 | -if ( !defined( 'WPSHOP_VERSION' ) ) { |
|
| 15 | - die( __('Access is not allowed by this way', 'wpshop') ); |
|
| 14 | +if (!defined('WPSHOP_VERSION')) { |
|
| 15 | + die(__('Access is not allowed by this way', 'wpshop')); |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | /** |
@@ -33,20 +33,20 @@ discard block |
||
| 33 | 33 | public static function create_wpshop_entities_type() { |
| 34 | 34 | register_post_type(WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, array( |
| 35 | 35 | 'labels' => array( |
| 36 | - 'name' => __( 'Entities', 'wpshop' ), |
|
| 37 | - 'singular_name' => __( 'Entity', 'wpshop' ), |
|
| 38 | - 'add_new_item' => __( 'Add new entity', 'wpshop' ), |
|
| 39 | - 'add_new' => __( 'Add new entity', 'wpshop' ), |
|
| 40 | - 'add_new_item' => __( 'Add new entity', 'wpshop' ), |
|
| 41 | - 'edit_item' => __( 'Edit entity', 'wpshop' ), |
|
| 42 | - 'new_item' => __( 'New entity', 'wpshop' ), |
|
| 43 | - 'view_item' => __( 'View entity', 'wpshop' ), |
|
| 44 | - 'search_items' => __( 'Search entities', 'wpshop' ), |
|
| 45 | - 'not_found' => __( 'No entities found', 'wpshop' ), |
|
| 46 | - 'not_found_in_trash' => __( 'No entities found in Trash', 'wpshop' ), |
|
| 36 | + 'name' => __('Entities', 'wpshop'), |
|
| 37 | + 'singular_name' => __('Entity', 'wpshop'), |
|
| 38 | + 'add_new_item' => __('Add new entity', 'wpshop'), |
|
| 39 | + 'add_new' => __('Add new entity', 'wpshop'), |
|
| 40 | + 'add_new_item' => __('Add new entity', 'wpshop'), |
|
| 41 | + 'edit_item' => __('Edit entity', 'wpshop'), |
|
| 42 | + 'new_item' => __('New entity', 'wpshop'), |
|
| 43 | + 'view_item' => __('View entity', 'wpshop'), |
|
| 44 | + 'search_items' => __('Search entities', 'wpshop'), |
|
| 45 | + 'not_found' => __('No entities found', 'wpshop'), |
|
| 46 | + 'not_found_in_trash' => __('No entities found in Trash', 'wpshop'), |
|
| 47 | 47 | 'parent_item_colon' => '', |
| 48 | 48 | ), |
| 49 | - 'supports' => array( 'title', 'editor', 'page-attributes' ), |
|
| 49 | + 'supports' => array('title', 'editor', 'page-attributes'), |
|
| 50 | 50 | 'public' => true, |
| 51 | 51 | 'has_archive' => true, |
| 52 | 52 | 'publicly_queryable' => false, |
@@ -76,13 +76,13 @@ discard block |
||
| 76 | 76 | /** Metabox allowgin to choose a custome rewrite for an entiy */ |
| 77 | 77 | add_meta_box(WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES . '_rewrite', __('Rewrite for entity', 'wpshop'), array('wpshop_entities', 'wpshop_entity_rewrite'), WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, 'normal', 'high'); |
| 78 | 78 | |
| 79 | - if ( !in_array( $post->post_name, unserialize( WPSHOP_DEFAULT_CUSTOM_TYPES ) ) ) { |
|
| 79 | + if (!in_array($post->post_name, unserialize(WPSHOP_DEFAULT_CUSTOM_TYPES))) { |
|
| 80 | 80 | /** Display or not address in admin menu */ |
| 81 | 81 | add_meta_box(WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES . '_admin_menu_display', __('Display in admin menu', 'wpshop'), array('wpshop_entities', 'wpshop_display_entity_in_admin_menu'), WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, 'side', 'low'); |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** Join address to entity */ |
| 85 | - if ( !in_array( $post->post_name, array( WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS ) ) ) { |
|
| 85 | + if (!in_array($post->post_name, array(WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS))) { |
|
| 86 | 86 | add_meta_box(WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES . '_join_address_to_entity', __('Join Address to this entity', 'wpshop'), array('wpshop_entities', 'wpshop_join_address_to_entity'), WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, 'side', 'low'); |
| 87 | 87 | } |
| 88 | 88 | } |
@@ -92,24 +92,24 @@ discard block |
||
| 92 | 92 | * |
| 93 | 93 | * @param object $post The entity type being edited |
| 94 | 94 | */ |
| 95 | - public static function wpshop_entity_support_section( $entity ) { |
|
| 95 | + public static function wpshop_entity_support_section($entity) { |
|
| 96 | 96 | $output = ''; |
| 97 | 97 | $support_list = unserialize(WPSHOP_REGISTER_POST_TYPE_SUPPORT); |
| 98 | 98 | |
| 99 | 99 | $current_entity_params = get_post_meta($entity->ID, '_wpshop_entity_params', true); |
| 100 | 100 | |
| 101 | - unset($input_def);$input_def=array(); |
|
| 101 | + unset($input_def); $input_def = array(); |
|
| 102 | 102 | $input_def['type'] = 'checkbox'; |
| 103 | 103 | |
| 104 | - foreach ( $support_list as $support ) { |
|
| 104 | + foreach ($support_list as $support) { |
|
| 105 | 105 | $input_def['id'] = 'wpshop_entity_support'; |
| 106 | 106 | $input_def['name'] = $support; |
| 107 | 107 | $input_def['possible_value'] = array($support); |
| 108 | - if ( !empty($current_entity_params['support']) && in_array($support, $current_entity_params['support']) ) { |
|
| 108 | + if (!empty($current_entity_params['support']) && in_array($support, $current_entity_params['support'])) { |
|
| 109 | 109 | $input_def['value'] = $support; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - $output .= '<p class="wpshop_entities_support_type wpshop_entities_support_type_' . $support . '" >' . wpshop_form::check_input_type($input_def, 'wpshop_entity_support') . ' <label for="'.$input_def['id'].'_'.$support.'">' . __($support, 'wpshop') . '</label></p>'; |
|
| 112 | + $output .= '<p class="wpshop_entities_support_type wpshop_entities_support_type_' . $support . '" >' . wpshop_form::check_input_type($input_def, 'wpshop_entity_support') . ' <label for="' . $input_def['id'] . '_' . $support . '">' . __($support, 'wpshop') . '</label></p>'; |
|
| 113 | 113 | } |
| 114 | 114 | $output .= '<p class="wpshop_cls" ></p>'; |
| 115 | 115 | |
@@ -121,33 +121,33 @@ discard block |
||
| 121 | 121 | * |
| 122 | 122 | * @param unknown_type $entity |
| 123 | 123 | */ |
| 124 | - public static function wpshop_entity_rewrite( $entity ) { |
|
| 124 | + public static function wpshop_entity_rewrite($entity) { |
|
| 125 | 125 | $output = ''; |
| 126 | 126 | |
| 127 | 127 | $current_entity_params = get_post_meta($entity->ID, '_wpshop_entity_params', true); |
| 128 | 128 | |
| 129 | - unset($input_def);$input_def=array(); |
|
| 129 | + unset($input_def); $input_def = array(); |
|
| 130 | 130 | $input_def['type'] = 'text'; |
| 131 | 131 | $input_def['id'] = 'wpshop_entity_rewrite'; |
| 132 | 132 | $input_def['name'] = 'wpshop_entity_rewrite[slug]'; |
| 133 | - $input_def['value'] = (!empty($current_entity_params['rewrite']['slug']) ? $current_entity_params['rewrite']['slug'] :''); |
|
| 133 | + $input_def['value'] = (!empty($current_entity_params['rewrite']['slug']) ? $current_entity_params['rewrite']['slug'] : ''); |
|
| 134 | 134 | |
| 135 | - $output .= '<p><label for="'.$input_def['id'].'">' . __('Choose how this entity will be rewrite in front side. If you let it empty default will be taken', 'wpshop') . '</label><br/>' . wpshop_form::check_input_type($input_def) . '</p>'; |
|
| 135 | + $output .= '<p><label for="' . $input_def['id'] . '">' . __('Choose how this entity will be rewrite in front side. If you let it empty default will be taken', 'wpshop') . '</label><br/>' . wpshop_form::check_input_type($input_def) . '</p>'; |
|
| 136 | 136 | |
| 137 | 137 | echo $output; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | public static function wpshop_display_entity_in_admin_menu() { |
| 141 | 141 | $checked = ''; |
| 142 | - $post = !empty( $_GET['post'] ) ? (int) $_GET['post'] : 0; |
|
| 143 | - if ( !empty($post) ) { |
|
| 144 | - $current_entity_params = get_post_meta( $post, '_wpshop_entity_params', true); |
|
| 142 | + $post = !empty($_GET['post']) ? (int)$_GET['post'] : 0; |
|
| 143 | + if (!empty($post)) { |
|
| 144 | + $current_entity_params = get_post_meta($post, '_wpshop_entity_params', true); |
|
| 145 | 145 | |
| 146 | - if ( !empty($current_entity_params['display_admin_menu']) ) { |
|
| 146 | + if (!empty($current_entity_params['display_admin_menu'])) { |
|
| 147 | 147 | $checked = 'checked ="checked"'; |
| 148 | 148 | } |
| 149 | 149 | } |
| 150 | - $output = '<input type="checkbox" id="wpshop_display_in_admin_menu" name="wpshop_display_in_admin_menu" ' .$checked. '/><label for="wpshop_display_in_admin_menu"> '.__('Display in admin menu', 'wpshop').'</label>'; |
|
| 150 | + $output = '<input type="checkbox" id="wpshop_display_in_admin_menu" name="wpshop_display_in_admin_menu" ' . $checked . '/><label for="wpshop_display_in_admin_menu"> ' . __('Display in admin menu', 'wpshop') . '</label>'; |
|
| 151 | 151 | echo $output; |
| 152 | 152 | } |
| 153 | 153 | |
@@ -155,21 +155,21 @@ discard block |
||
| 155 | 155 | * Save custom information for entity type |
| 156 | 156 | */ |
| 157 | 157 | public static function save_entity_type_custom_informations() { |
| 158 | - $post_id = !empty($_POST['post_ID']) ? intval( sanitize_key($_POST['post_ID']) ) : null; |
|
| 159 | - $post_support = !empty($_POST['wpshop_entity_support']) && is_array( (array)$_POST['wpshop_entity_support'] ) ? (array)$_POST['wpshop_entity_support'] : null; |
|
| 160 | - $wpshop_entity_rewrite = !empty($_POST['wpshop_entity_rewrite']) ? (array) $_POST['wpshop_entity_rewrite'] : null; |
|
| 158 | + $post_id = !empty($_POST['post_ID']) ? intval(sanitize_key($_POST['post_ID'])) : null; |
|
| 159 | + $post_support = !empty($_POST['wpshop_entity_support']) && is_array((array)$_POST['wpshop_entity_support']) ? (array)$_POST['wpshop_entity_support'] : null; |
|
| 160 | + $wpshop_entity_rewrite = !empty($_POST['wpshop_entity_rewrite']) ? (array)$_POST['wpshop_entity_rewrite'] : null; |
|
| 161 | 161 | $wpshop_entity_display_menu = !empty($_POST['wpshop_display_in_admin_menu']) ? sanitize_key($_POST['wpshop_display_in_admin_menu']) : null; |
| 162 | 162 | |
| 163 | - $address_type = !empty ($_POST['address_type']) ? (array) $_POST['address_type'] : null; |
|
| 164 | - if ( isset($address_type) ) { |
|
| 163 | + $address_type = !empty ($_POST['address_type']) ? (array)$_POST['address_type'] : null; |
|
| 164 | + if (isset($address_type)) { |
|
| 165 | 165 | $save_array = array(); |
| 166 | - foreach ( $address_type as $key=>$value ) { |
|
| 167 | - $save_array[] = intval( sanitize_text_field($value) ); |
|
| 166 | + foreach ($address_type as $key=>$value) { |
|
| 167 | + $save_array[] = intval(sanitize_text_field($value)); |
|
| 168 | 168 | } |
| 169 | - update_post_meta( $post_id, '_wpshop_entity_attached_address', $save_array ); |
|
| 169 | + update_post_meta($post_id, '_wpshop_entity_attached_address', $save_array); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - if ( get_post_type($post_id) == WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES ) { |
|
| 172 | + if (get_post_type($post_id) == WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES) { |
|
| 173 | 173 | update_post_meta($post_id, '_wpshop_entity_params', array('support' => $post_support, 'rewrite' => $wpshop_entity_rewrite, 'display_admin_menu'=>$wpshop_entity_display_menu)); |
| 174 | 174 | flush_rewrite_rules(); |
| 175 | 175 | } |
@@ -178,19 +178,19 @@ discard block |
||
| 178 | 178 | /** |
| 179 | 179 | * Permite to join one or several address to an entity |
| 180 | 180 | */ |
| 181 | - public static function wpshop_join_address_to_entity () { |
|
| 181 | + public static function wpshop_join_address_to_entity() { |
|
| 182 | 182 | global $wpdb; |
| 183 | 183 | // Select the id of the entity address |
| 184 | - $query = $wpdb->prepare('SELECT id FROM ' .$wpdb->posts. ' WHERE post_type = %s AND post_name = %s', WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS); |
|
| 185 | - $entity_id = $wpdb->get_var( $query ); |
|
| 184 | + $query = $wpdb->prepare('SELECT id FROM ' . $wpdb->posts . ' WHERE post_type = %s AND post_name = %s', WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS); |
|
| 185 | + $entity_id = $wpdb->get_var($query); |
|
| 186 | 186 | //Get the Post_meta |
| 187 | - $attached_address_values = get_post_meta( intval(wpshop_tools::varSanitizer( (!empty($_GET['post']) ? $_GET['post'] : '') )), '_wpshop_entity_attached_address', true ); |
|
| 187 | + $attached_address_values = get_post_meta(intval(wpshop_tools::varSanitizer((!empty($_GET['post']) ? $_GET['post'] : ''))), '_wpshop_entity_attached_address', true); |
|
| 188 | 188 | //Select and Display all addresses type |
| 189 | - $query = $wpdb->prepare('SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE_SET. ' WHERE entity_id = %d', $entity_id); |
|
| 190 | - $addresses = $wpdb->get_results( $query); |
|
| 189 | + $query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d', $entity_id); |
|
| 190 | + $addresses = $wpdb->get_results($query); |
|
| 191 | 191 | $output = ''; |
| 192 | - foreach ( $addresses as $address ) { |
|
| 193 | - $output .= '<p><input type="checkbox" id="' .$address->name.'_'.$address->id.'" name="address_type[' .$address->name. ']" value="'.$address->id.'" ' .( ( !empty($attached_address_values) && in_array( $address->id, $attached_address_values) ) ? 'checked="checked"' : '' ). ' /> <label for="' .$address->name.'_'.$address->id.'">'.$address->name.'</label></p>'; |
|
| 192 | + foreach ($addresses as $address) { |
|
| 193 | + $output .= '<p><input type="checkbox" id="' . $address->name . '_' . $address->id . '" name="address_type[' . $address->name . ']" value="' . $address->id . '" ' . ((!empty($attached_address_values) && in_array($address->id, $attached_address_values)) ? 'checked="checked"' : '') . ' /> <label for="' . $address->name . '_' . $address->id . '">' . $address->name . '</label></p>'; |
|
| 194 | 194 | } |
| 195 | 195 | echo $output; |
| 196 | 196 | } |
@@ -210,12 +210,12 @@ discard block |
||
| 210 | 210 | /* |
| 211 | 211 | * Read the entity list for custom type declaration |
| 212 | 212 | */ |
| 213 | - if ( !empty($entities) ) { |
|
| 214 | - foreach ( $entities as $entity ) { |
|
| 215 | - $wpshop_builtin_types = unserialize( WPSHOP_DEFAULT_CUSTOM_TYPES ); |
|
| 216 | - if ( !empty( $entity->post_name ) && !in_array( $entity->post_name, $wpshop_builtin_types ) ) { |
|
| 213 | + if (!empty($entities)) { |
|
| 214 | + foreach ($entities as $entity) { |
|
| 215 | + $wpshop_builtin_types = unserialize(WPSHOP_DEFAULT_CUSTOM_TYPES); |
|
| 216 | + if (!empty($entity->post_name) && !in_array($entity->post_name, $wpshop_builtin_types)) { |
|
| 217 | 217 | $current_entity_params = get_post_meta($entity->ID, '_wpshop_entity_params', true); |
| 218 | - if ( !empty($current_entity_params['display_admin_menu']) ) { |
|
| 218 | + if (!empty($current_entity_params['display_admin_menu'])) { |
|
| 219 | 219 | $show_in_menu = WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES; |
| 220 | 220 | } |
| 221 | 221 | else { |
@@ -223,17 +223,17 @@ discard block |
||
| 223 | 223 | } |
| 224 | 224 | $post_type_params = array( |
| 225 | 225 | 'labels' => array( |
| 226 | - 'name' => __( $entity->post_title , 'wpshop' ), |
|
| 227 | - 'singular_name' => __( $entity->post_title, 'wpshop' ), |
|
| 228 | - 'add_new_item' => sprintf( __( 'Add new %s', 'wpshop' ), $entity->post_title), |
|
| 229 | - 'add_new' => sprintf( __( 'Add new %s', 'wpshop' ), $entity->post_title), |
|
| 230 | - 'add_new_item' => sprintf( __( 'Add new %s', 'wpshop' ), $entity->post_title), |
|
| 231 | - 'edit_item' => sprintf( __( 'Edit %s', 'wpshop' ), $entity->post_title), |
|
| 232 | - 'new_item' => sprintf( __( 'New %s', 'wpshop' ), $entity->post_title), |
|
| 233 | - 'view_item' => sprintf( __( 'View %s', 'wpshop' ), $entity->post_title), |
|
| 234 | - 'search_items' => sprintf( __( 'Search %s', 'wpshop' ), $entity->post_title), |
|
| 235 | - 'not_found' => sprintf( __( 'No %s found', 'wpshop' ), $entity->post_title), |
|
| 236 | - 'not_found_in_trash' => sprintf( __( 'No %s found in Trash', 'wpshop' ), $entity->post_title), |
|
| 226 | + 'name' => __($entity->post_title, 'wpshop'), |
|
| 227 | + 'singular_name' => __($entity->post_title, 'wpshop'), |
|
| 228 | + 'add_new_item' => sprintf(__('Add new %s', 'wpshop'), $entity->post_title), |
|
| 229 | + 'add_new' => sprintf(__('Add new %s', 'wpshop'), $entity->post_title), |
|
| 230 | + 'add_new_item' => sprintf(__('Add new %s', 'wpshop'), $entity->post_title), |
|
| 231 | + 'edit_item' => sprintf(__('Edit %s', 'wpshop'), $entity->post_title), |
|
| 232 | + 'new_item' => sprintf(__('New %s', 'wpshop'), $entity->post_title), |
|
| 233 | + 'view_item' => sprintf(__('View %s', 'wpshop'), $entity->post_title), |
|
| 234 | + 'search_items' => sprintf(__('Search %s', 'wpshop'), $entity->post_title), |
|
| 235 | + 'not_found' => sprintf(__('No %s found', 'wpshop'), $entity->post_title), |
|
| 236 | + 'not_found_in_trash' => sprintf(__('No %s found in Trash', 'wpshop'), $entity->post_title), |
|
| 237 | 237 | 'parent_item_colon' => '', |
| 238 | 238 | ), |
| 239 | 239 | 'description' => $entity->post_content, |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | 'rewrite' => !empty($current_entity_params['rewrite']) ? $current_entity_params['rewrite'] : array(), |
| 248 | 248 | 'hierarchical' => true, |
| 249 | 249 | ); |
| 250 | - register_post_type($entity->post_name, $post_type_params ); |
|
| 250 | + register_post_type($entity->post_name, $post_type_params); |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | /** Add basic metabox */ |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | - add_filter( 'map_meta_cap', array('wpshop_entities', 'map_meta_cap'), 10, 4 ); |
|
| 261 | + add_filter('map_meta_cap', array('wpshop_entities', 'map_meta_cap'), 10, 4); |
|
| 262 | 262 | /* |
| 263 | 263 | * Reset query for security reasons |
| 264 | 264 | */ |
@@ -273,10 +273,10 @@ discard block |
||
| 273 | 273 | * @param integer $user_id |
| 274 | 274 | * @param array $args |
| 275 | 275 | */ |
| 276 | - public static function map_meta_cap( $caps, $cap, $user_id, $args ) { |
|
| 277 | - if ( !empty($args) ) { |
|
| 276 | + public static function map_meta_cap($caps, $cap, $user_id, $args) { |
|
| 277 | + if (!empty($args)) { |
|
| 278 | 278 | $post = get_post($args[0]); |
| 279 | - if ( false && !empty($post) && is_object($post) && ($post->post_type == WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES) && (($post->post_name == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) || ($post->post_name == WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS) || ($post->post_name == WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS)) && ($cap == 'delete_product') ) { |
|
| 279 | + if (false && !empty($post) && is_object($post) && ($post->post_type == WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES) && (($post->post_name == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) || ($post->post_name == WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS) || ($post->post_name == WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS)) && ($cap == 'delete_product')) { |
|
| 280 | 280 | $caps = 'wpshop_view_dashboard'; |
| 281 | 281 | } |
| 282 | 282 | } |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | /** |
| 289 | 289 | * Add metaboxes to the custom post types defined by entities |
| 290 | 290 | */ |
| 291 | - public static function add_meta_boxes_to_custom_types( $post ) { |
|
| 291 | + public static function add_meta_boxes_to_custom_types($post) { |
|
| 292 | 292 | global $post, |
| 293 | 293 | $wpdb; |
| 294 | 294 | |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | /* |
| 304 | 304 | * Product are managed from another place |
| 305 | 305 | */ |
| 306 | - if ( $post->post_type != WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ) { |
|
| 306 | + if ($post->post_type != WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) { |
|
| 307 | 307 | /* |
| 308 | 308 | * Get the attribute set list for current entity |
| 309 | 309 | */ |
@@ -314,8 +314,8 @@ discard block |
||
| 314 | 314 | */ |
| 315 | 315 | $attribute_set_id = get_post_meta($post->ID, sprintf(WPSHOP_ATTRIBUTE_SET_ID_META_KEY, $post->post_type), true); |
| 316 | 316 | |
| 317 | - if(((count($attribute_set_list) == 1) || ((count($attribute_set_list) > 1) && !empty($attribute_set_id)))){ |
|
| 318 | - if((count($attribute_set_list) == 1) || empty($attribute_set_id)){ |
|
| 317 | + if (((count($attribute_set_list) == 1) || ((count($attribute_set_list) > 1) && !empty($attribute_set_id)))) { |
|
| 318 | + if ((count($attribute_set_list) == 1) || empty($attribute_set_id)) { |
|
| 319 | 319 | $attribute_set_id = $attribute_set_list[0]->id; |
| 320 | 320 | } |
| 321 | 321 | |
@@ -328,28 +328,28 @@ discard block |
||
| 328 | 328 | /* |
| 329 | 329 | * Read the different element for building output for current entity |
| 330 | 330 | */ |
| 331 | - if ( !empty($currentTabContent['box']) && is_array($currentTabContent['box']) ) { |
|
| 331 | + if (!empty($currentTabContent['box']) && is_array($currentTabContent['box'])) { |
|
| 332 | 332 | foreach ($currentTabContent['box'] as $boxIdentifier => $boxTitle) { |
| 333 | - if (!empty($currentTabContent['box'][$boxIdentifier.'_backend_display_type']) &&( $currentTabContent['box'][$boxIdentifier.'_backend_display_type']=='movable-tab')) { |
|
| 333 | + if (!empty($currentTabContent['box'][$boxIdentifier . '_backend_display_type']) && ($currentTabContent['box'][$boxIdentifier . '_backend_display_type'] == 'movable-tab')) { |
|
| 334 | 334 | add_meta_box($post->post_type . '_' . $boxIdentifier, __($boxTitle, 'wpshop'), array('wpshop_entities', 'meta_box_content'), $post->post_type, 'normal', 'default', array('currentTabContent' => $currentTabContent['boxContent'][$boxIdentifier])); |
| 335 | 335 | } |
| 336 | 336 | else $fixed_box_exist = true; |
| 337 | 337 | } |
| 338 | 338 | } |
| 339 | - if ($fixed_box_exist && $post->post_type != WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ) { |
|
| 339 | + if ($fixed_box_exist && $post->post_type != WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS) { |
|
| 340 | 340 | add_meta_box($post->post_type . '_fixed_tab', __('Informations', 'wpshop'), array('wpshop_entities', 'meta_box_content_datas'), $post->post_type, 'normal', 'high', array('currentTabContent' => $currentTabContent)); |
| 341 | 341 | } |
| 342 | 342 | } |
| 343 | 343 | elseif (count($attribute_set_list) > 1) { |
| 344 | - $input_def['id'] = $post->post_type.'_attribute_set_id'; |
|
| 345 | - $input_def['name'] = $post->post_type.'_attribute_set_id'; |
|
| 344 | + $input_def['id'] = $post->post_type . '_attribute_set_id'; |
|
| 345 | + $input_def['name'] = $post->post_type . '_attribute_set_id'; |
|
| 346 | 346 | $input_def['value'] = ''; |
| 347 | 347 | $input_def['type'] = 'select'; |
| 348 | 348 | $input_def['possible_value'] = $attribute_set_list; |
| 349 | 349 | |
| 350 | 350 | $input_def['value'] = ''; |
| 351 | 351 | foreach ($attribute_set_list as $set) { |
| 352 | - if( $set->default_set == 'yes' ) { |
|
| 352 | + if ($set->default_set == 'yes') { |
|
| 353 | 353 | $input_def['value'] = $set->id; |
| 354 | 354 | } |
| 355 | 355 | } |
@@ -357,12 +357,12 @@ discard block |
||
| 357 | 357 | $currentTabContent = ' |
| 358 | 358 | <ul class="attribute_set_selector" > |
| 359 | 359 | <li class="attribute_set_selector_title_select" ><label for="title" >' . sprintf(__('Choose a title for the %s', 'wpshop'), get_the_title(wpshop_entities::get_entity_identifier_from_code($post->post_type))) . '</label></li> |
| 360 | - <li class="attribute_set_selector_group_selector" ><label for="' . $input_def['id'] . '" >' . sprintf(__('Choose an attribute group for this %s', 'wpshop'), get_the_title(wpshop_entities::get_entity_identifier_from_code($post->post_type))) . '</label> '.wpshop_form::check_input_type($input_def).'</li> |
|
| 360 | + <li class="attribute_set_selector_group_selector" ><label for="' . $input_def['id'] . '" >' . sprintf(__('Choose an attribute group for this %s', 'wpshop'), get_the_title(wpshop_entities::get_entity_identifier_from_code($post->post_type))) . '</label> ' . wpshop_form::check_input_type($input_def) . '</li> |
|
| 361 | 361 | <li class="attribute_set_selector_save_instruction" >' . sprintf(__('Save the %s with the "Save draft" button on the right side', 'wpshop'), get_the_title(wpshop_entities::get_entity_identifier_from_code($post->post_type))) . '</li> |
| 362 | 362 | <li class="attribute_set_selector_after_save_instruction" >' . __('Once the group chosen, the different attribute will be displayed here', 'wpshop') . '</li> |
| 363 | 363 | </ul>'; |
| 364 | 364 | |
| 365 | - add_meta_box($post->post_type . '_attribute_set_selector',sprintf( __('%s attributes', 'wpshop'), get_the_title(wpshop_entities::get_entity_identifier_from_code($post->post_type))), array('wpshop_entities', 'meta_box_content'), $post->post_type, 'normal', 'high', array('currentTabContent' => $currentTabContent)); |
|
| 365 | + add_meta_box($post->post_type . '_attribute_set_selector', sprintf(__('%s attributes', 'wpshop'), get_the_title(wpshop_entities::get_entity_identifier_from_code($post->post_type))), array('wpshop_entities', 'meta_box_content'), $post->post_type, 'normal', 'high', array('currentTabContent' => $currentTabContent)); |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | } |
@@ -392,22 +392,22 @@ discard block |
||
| 392 | 392 | |
| 393 | 393 | echo '<div id="fixed-tabs" class="wpshop_tabs wpshop_detail_tabs entities_attribute_tabs ' . $post->post_type . '_attribute_tabs" > |
| 394 | 394 | <ul>'; |
| 395 | - if(!empty($currentTabContent['box'])){ |
|
| 396 | - foreach($currentTabContent['box'] as $boxIdentifier => $boxTitle){ |
|
| 397 | - if(!empty($currentTabContent['boxContent'][$boxIdentifier])) { |
|
| 398 | - if($currentTabContent['box'][$boxIdentifier.'_backend_display_type']=='fixed-tab') { |
|
| 399 | - echo '<li><a href="#tabs-'.$boxIdentifier.'">'.__($boxTitle, 'wpshop').'</a></li>'; |
|
| 395 | + if (!empty($currentTabContent['box'])) { |
|
| 396 | + foreach ($currentTabContent['box'] as $boxIdentifier => $boxTitle) { |
|
| 397 | + if (!empty($currentTabContent['boxContent'][$boxIdentifier])) { |
|
| 398 | + if ($currentTabContent['box'][$boxIdentifier . '_backend_display_type'] == 'fixed-tab') { |
|
| 399 | + echo '<li><a href="#tabs-' . $boxIdentifier . '">' . __($boxTitle, 'wpshop') . '</a></li>'; |
|
| 400 | 400 | } |
| 401 | 401 | } |
| 402 | 402 | } |
| 403 | 403 | } |
| 404 | 404 | echo '</ul>'; |
| 405 | 405 | |
| 406 | - if(!empty($currentTabContent['box'])){ |
|
| 407 | - foreach($currentTabContent['box'] as $boxIdentifier => $boxTitle){ |
|
| 408 | - if(!empty($currentTabContent['boxContent'][$boxIdentifier])) { |
|
| 409 | - if($currentTabContent['box'][$boxIdentifier.'_backend_display_type']=='fixed-tab') { |
|
| 410 | - echo '<div id="tabs-'.$boxIdentifier.'">'.$currentTabContent['boxContent'][$boxIdentifier].'</div>'; |
|
| 406 | + if (!empty($currentTabContent['box'])) { |
|
| 407 | + foreach ($currentTabContent['box'] as $boxIdentifier => $boxTitle) { |
|
| 408 | + if (!empty($currentTabContent['boxContent'][$boxIdentifier])) { |
|
| 409 | + if ($currentTabContent['box'][$boxIdentifier . '_backend_display_type'] == 'fixed-tab') { |
|
| 410 | + echo '<div id="tabs-' . $boxIdentifier . '">' . $currentTabContent['boxContent'][$boxIdentifier] . '</div>'; |
|
| 411 | 411 | } |
| 412 | 412 | } |
| 413 | 413 | } |
@@ -422,32 +422,32 @@ discard block |
||
| 422 | 422 | /** |
| 423 | 423 | * Save informations for current entity |
| 424 | 424 | */ |
| 425 | - public static function save_entities_custom_informations( $post_id ) { |
|
| 425 | + public static function save_entities_custom_informations($post_id) { |
|
| 426 | 426 | global $wpdb, $wpshop_account; |
| 427 | 427 | |
| 428 | - $edit_other_thing = !empty( $_POST['edit_other_thing'] ) ? (int) $_POST['edit_other_thing'] : 0; |
|
| 428 | + $edit_other_thing = !empty($_POST['edit_other_thing']) ? (int)$_POST['edit_other_thing'] : 0; |
|
| 429 | 429 | |
| 430 | - if ( ( ( !empty($post_id) && empty( $edit_other_thing ) ) || ( !empty($post_id) && !(bool)$edit_other_thing ) ) |
|
| 431 | - && ( get_post_type( $post_id ) != WPSHOP_NEWTYPE_IDENTIFIER_ORDER ) ) { |
|
| 432 | - $current_post_type = get_post_type( $post_id ); |
|
| 433 | - $current_post_type_text = !empty( $_REQUEST[$current_post_type . '_attribute_set_id'] ) ? sanitize_text_field( $_REQUEST[$current_post_type . '_attribute_set_id'] ) : ''; |
|
| 430 | + if (((!empty($post_id) && empty($edit_other_thing)) || (!empty($post_id) && !(bool)$edit_other_thing)) |
|
| 431 | + && (get_post_type($post_id) != WPSHOP_NEWTYPE_IDENTIFIER_ORDER)) { |
|
| 432 | + $current_post_type = get_post_type($post_id); |
|
| 433 | + $current_post_type_text = !empty($_REQUEST[$current_post_type . '_attribute_set_id']) ? sanitize_text_field($_REQUEST[$current_post_type . '_attribute_set_id']) : ''; |
|
| 434 | 434 | /* Vérification de l'existence de l'envoi de l'identifiant du set d'attribut */ |
| 435 | - if ( !empty($current_post_type_text) ) { |
|
| 436 | - $attribute_set_id = intval( $current_post_type_text ); |
|
| 435 | + if (!empty($current_post_type_text)) { |
|
| 436 | + $attribute_set_id = intval($current_post_type_text); |
|
| 437 | 437 | $attribet_set_infos = wpshop_attributes_set::getElement($attribute_set_id, "'valid'", 'id'); |
| 438 | 438 | |
| 439 | - if ( $attribet_set_infos->entity == sanitize_key( $current_post_type ) ) { |
|
| 439 | + if ($attribet_set_infos->entity == sanitize_key($current_post_type)) { |
|
| 440 | 440 | /* Enregistrement de l'identifiant du set d'attribut associé à l'entité */ |
| 441 | 441 | update_post_meta($post_id, sprintf(WPSHOP_ATTRIBUTE_SET_ID_META_KEY, $current_post_type), $attribute_set_id); |
| 442 | 442 | |
| 443 | 443 | /* Enregistrement de tous les attributs */ |
| 444 | 444 | $current_post_type_attributes = !empty($_REQUEST[$current_post_type . '_attribute']) ? (array)$_REQUEST[$current_post_type . '_attribute'] : null; |
| 445 | - if ( isset($current_post_type_attributes) ) { |
|
| 445 | + if (isset($current_post_type_attributes)) { |
|
| 446 | 446 | /* Traduction des virgule en point pour la base de donnees */ |
| 447 | - if ( !empty($current_post_type_attributes['decimal']) ) { |
|
| 448 | - foreach($current_post_type_attributes['decimal'] as $attributeName => $attributeValue){ |
|
| 449 | - if(!is_array($attributeValue)){ |
|
| 450 | - $current_post_type_attributes['decimal'][$attributeName] = str_replace(',','.',$current_post_type_attributes['decimal'][$attributeName]); |
|
| 447 | + if (!empty($current_post_type_attributes['decimal'])) { |
|
| 448 | + foreach ($current_post_type_attributes['decimal'] as $attributeName => $attributeValue) { |
|
| 449 | + if (!is_array($attributeValue)) { |
|
| 450 | + $current_post_type_attributes['decimal'][$attributeName] = str_replace(',', '.', $current_post_type_attributes['decimal'][$attributeName]); |
|
| 451 | 451 | } |
| 452 | 452 | } |
| 453 | 453 | } |
@@ -456,8 +456,8 @@ discard block |
||
| 456 | 456 | |
| 457 | 457 | /* Enregistrement des valeurs des attributs dans les metas de l'entité => Permet de profiter de la recherche native de wordpress */ |
| 458 | 458 | $productMetaDatas = array(); |
| 459 | - foreach ( $current_post_type_attributes as $attributeType => $attributeValues ) { |
|
| 460 | - foreach ( $attributeValues as $attributeCode => $attributeValue ) { |
|
| 459 | + foreach ($current_post_type_attributes as $attributeType => $attributeValues) { |
|
| 460 | + foreach ($attributeValues as $attributeCode => $attributeValue) { |
|
| 461 | 461 | $productMetaDatas[$attributeCode] = $attributeValue; |
| 462 | 462 | } |
| 463 | 463 | } |
@@ -467,42 +467,42 @@ discard block |
||
| 467 | 467 | } |
| 468 | 468 | } |
| 469 | 469 | |
| 470 | - $attribute = !empty($_REQUEST['attribute']) ? (array) $_REQUEST['attribute'] : null; |
|
| 471 | - $post_id = !empty($_REQUEST['post_ID']) ? (int) $_REQUEST['post_ID'] : null; |
|
| 472 | - if ( isset($attribute) ) { |
|
| 470 | + $attribute = !empty($_REQUEST['attribute']) ? (array)$_REQUEST['attribute'] : null; |
|
| 471 | + $post_id = !empty($_REQUEST['post_ID']) ? (int)$_REQUEST['post_ID'] : null; |
|
| 472 | + if (isset($attribute)) { |
|
| 473 | 473 | $current_id = array(); |
| 474 | - foreach ( $attribute as $key=>$values ) { |
|
| 474 | + foreach ($attribute as $key=>$values) { |
|
| 475 | 475 | $ad_id = ''; |
| 476 | 476 | $addresses_id = get_post_meta($post_id, '_wpshop_attached_address', true); |
| 477 | - if ( !empty($addresses_id) ) { |
|
| 478 | - foreach ( $addresses_id as $address_id) { |
|
| 477 | + if (!empty($addresses_id)) { |
|
| 478 | + foreach ($addresses_id as $address_id) { |
|
| 479 | 479 | $address_type = get_post_meta($address_id, '_wpshop_address_attribute_set_id', true); |
| 480 | 480 | if ($address_type == $key) { |
| 481 | 481 | $ad_id = $address_id; |
| 482 | 482 | } |
| 483 | 483 | } |
| 484 | 484 | } |
| 485 | - if( !empty( $ad_id ) ) { |
|
| 485 | + if (!empty($ad_id)) { |
|
| 486 | 486 | // @TODO : REQUEST |
| 487 | 487 | // $_REQUEST['item_id'] = $ad_id; |
| 488 | - $result = wps_address::save_address_infos( $key ); |
|
| 488 | + $result = wps_address::save_address_infos($key); |
|
| 489 | 489 | $current_id[] = $result['current_id']; |
| 490 | 490 | } |
| 491 | 491 | } |
| 492 | - if( !empty( $current_id ) ) { |
|
| 493 | - update_post_meta ($post_id, '_wpshop_attached_address', $current_id); |
|
| 492 | + if (!empty($current_id)) { |
|
| 493 | + update_post_meta($post_id, '_wpshop_attached_address', $current_id); |
|
| 494 | 494 | } |
| 495 | 495 | } |
| 496 | 496 | else { |
| 497 | 497 | $current_id = array(); |
| 498 | 498 | |
| 499 | - $address_type = !empty($_REQUEST['address_type']) ? (array) $_REQUEST['address_type'] : null; |
|
| 500 | - if ( isset($address_type) ) { |
|
| 501 | - foreach ( $address_type as $key=>$value ) { |
|
| 499 | + $address_type = !empty($_REQUEST['address_type']) ? (array)$_REQUEST['address_type'] : null; |
|
| 500 | + if (isset($address_type)) { |
|
| 501 | + foreach ($address_type as $key=>$value) { |
|
| 502 | 502 | $current_id[] = $value; |
| 503 | 503 | } |
| 504 | 504 | } |
| 505 | - update_post_meta ($post_id, '_wpshop_entity_attached_address', $current_id); |
|
| 505 | + update_post_meta($post_id, '_wpshop_entity_attached_address', $current_id); |
|
| 506 | 506 | } |
| 507 | 507 | } |
| 508 | 508 | |
@@ -525,7 +525,7 @@ discard block |
||
| 525 | 525 | 'posts_per_page' => '-1', |
| 526 | 526 | )); |
| 527 | 527 | |
| 528 | - if ( !empty($entities) ) { |
|
| 528 | + if (!empty($entities)) { |
|
| 529 | 529 | foreach ($entities as $entity_index => $entity) { |
| 530 | 530 | $entities_list[$entity->ID] = $entity->post_title; |
| 531 | 531 | } |
@@ -544,7 +544,7 @@ discard block |
||
| 544 | 544 | * @return integer The entity identifier that match to given parameters |
| 545 | 545 | */ |
| 546 | 546 | public static function get_entity_identifier_from_code($code, $post_status = 'publish', $entity_code = WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES) { |
| 547 | - if ( ! isset( self::$entities_cache[$entity_code][$code][$post_status] ) ) { |
|
| 547 | + if (!isset(self::$entities_cache[$entity_code][$code][$post_status])) { |
|
| 548 | 548 | global $wpdb; |
| 549 | 549 | self::$entities_cache[$entity_code][$code][$post_status] = null; |
| 550 | 550 | $query = $wpdb->prepare("SELECT ID FROM " . $wpdb->posts . " WHERE post_type=%s AND post_status=%s AND post_name=%s ORDER BY menu_order ASC", $entity_code, $post_status, $code); |
@@ -563,7 +563,7 @@ discard block |
||
| 563 | 563 | global $wpdb; |
| 564 | 564 | |
| 565 | 565 | /* Get current post information */ |
| 566 | - $post_infos = get_post( $post_id, ARRAY_A ); |
|
| 566 | + $post_infos = get_post($post_id, ARRAY_A); |
|
| 567 | 567 | /* Set new information for post that will be created */ |
| 568 | 568 | unset($post_infos['ID']); |
| 569 | 569 | $post_infos['post_date'] = current_time('mysql', 1); |
@@ -581,18 +581,18 @@ discard block |
||
| 581 | 581 | $last_post = wp_insert_post($post_infos); |
| 582 | 582 | |
| 583 | 583 | /* If there is no error then duplicate meta informations */ |
| 584 | - if ( is_int($last_post) && !empty($last_post) ) { |
|
| 584 | + if (is_int($last_post) && !empty($last_post)) { |
|
| 585 | 585 | $meta_creation = true; |
| 586 | 586 | |
| 587 | 587 | $current_post_meta = get_post_meta($post_id); |
| 588 | - foreach ( $current_post_meta as $post_meta_key => $post_meta_value ) { |
|
| 589 | - $meta_is_array = ( !empty( $post_meta_value[0] ) && wpshop_tools::is_serialized( $post_meta_value[0] ) ) ? unserialize( $post_meta_value[0] ) : ''; |
|
| 588 | + foreach ($current_post_meta as $post_meta_key => $post_meta_value) { |
|
| 589 | + $meta_is_array = (!empty($post_meta_value[0]) && wpshop_tools::is_serialized($post_meta_value[0])) ? unserialize($post_meta_value[0]) : ''; |
|
| 590 | 590 | $meta_real_value = (is_array($meta_is_array) ? $meta_is_array : $post_meta_value[0]); |
| 591 | 591 | $meta_creation = update_post_meta($last_post, $post_meta_key, $meta_real_value); |
| 592 | 592 | } |
| 593 | 593 | /* Duplicate element taxonomy */ |
| 594 | 594 | /* Check the taxonomy to get */ |
| 595 | - switch ( get_post_type($post_id) ) { |
|
| 595 | + switch (get_post_type($post_id)) { |
|
| 596 | 596 | case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT: |
| 597 | 597 | $taxonomy = WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES; |
| 598 | 598 | break; |
@@ -600,17 +600,17 @@ discard block |
||
| 600 | 600 | $taxonomy = ''; |
| 601 | 601 | break; |
| 602 | 602 | } |
| 603 | - $post_taxonomies = wp_get_post_terms( $post_id, $taxonomy); |
|
| 604 | - foreach ( $post_taxonomies as $post_taxonomy ) { |
|
| 605 | - wp_set_post_terms( $last_post, $post_taxonomy->term_id, $taxonomy, true); |
|
| 603 | + $post_taxonomies = wp_get_post_terms($post_id, $taxonomy); |
|
| 604 | + foreach ($post_taxonomies as $post_taxonomy) { |
|
| 605 | + wp_set_post_terms($last_post, $post_taxonomy->term_id, $taxonomy, true); |
|
| 606 | 606 | } |
| 607 | 607 | |
| 608 | 608 | /* Create a post meta allowing to know if the element has been duplicated from another */ |
| 609 | 609 | update_post_meta($last_post, '_wpshop_duplicate_element', $post_id); |
| 610 | 610 | |
| 611 | 611 | $new_element_link = '<a class="wpshop_cls wpshop_duplicate_entity_element_link" href="' . admin_url('post.php?post=' . $last_post . '&action=edit') . '" >' . __('Go on the new element edit page', 'wpshop') . '</a>'; |
| 612 | - if ( $meta_creation ) { |
|
| 613 | - return array('true', '<br/>' . $new_element_link, $last_post ); |
|
| 612 | + if ($meta_creation) { |
|
| 613 | + return array('true', '<br/>' . $new_element_link, $last_post); |
|
| 614 | 614 | } |
| 615 | 615 | else { |
| 616 | 616 | return array('true', '<br/>' . __('Some errors occured while duplicating meta information, but element has been created.', 'wpshop') . ' ' . $new_element_link); |
@@ -636,12 +636,12 @@ discard block |
||
| 636 | 636 | $query = $wpdb->prepare("SELECT code, frontend_label FROM " . WPSHOP_DBT_ATTRIBUTE . " AS ATT WHERE status=%s AND is_used_in_admin_listing_column=%s AND entity_id=%d", 'valid', 'yes', self::get_entity_identifier_from_code($post_type)); |
| 637 | 637 | $attributes_list = $wpdb->get_results($query); |
| 638 | 638 | $wpshop_custom_columns = array(); |
| 639 | - foreach ( $attributes_list as $attribute ) { |
|
| 639 | + foreach ($attributes_list as $attribute) { |
|
| 640 | 640 | $wpshop_custom_columns[$attribute->code] = __($attribute->frontend_label, 'wpshop'); |
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | /* Check the current entity to display custom column correctly. Add the custom column into default column list */ |
| 644 | - switch ( $post_type ) { |
|
| 644 | + switch ($post_type) { |
|
| 645 | 645 | case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT: |
| 646 | 646 | $columns = array_merge(array( |
| 647 | 647 | 'cb' => '<input type="checkbox" />', |
@@ -668,34 +668,34 @@ discard block |
||
| 668 | 668 | public static function custom_columns_content($column, $post_id) { |
| 669 | 669 | $post_type = get_post_type($post_id); |
| 670 | 670 | |
| 671 | - switch ( $post_type ) { |
|
| 671 | + switch ($post_type) { |
|
| 672 | 672 | case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT: |
| 673 | 673 | $column_content = '<strong>-</strong>'; |
| 674 | 674 | $product = wpshop_products::get_product_data($post_id); |
| 675 | 675 | |
| 676 | 676 | switch ($column) { |
| 677 | 677 | case 'picture' : |
| 678 | - $column_content = get_the_post_thumbnail( $post_id, 'thumbnail'); |
|
| 678 | + $column_content = get_the_post_thumbnail($post_id, 'thumbnail'); |
|
| 679 | 679 | break; |
| 680 | 680 | case "product_stock": |
| 681 | - if( !empty($product['product_stock']) ) |
|
| 682 | - $column_content = (int)$product['product_stock'].' '.__('unit(s)','wpshop'); |
|
| 681 | + if (!empty($product['product_stock'])) |
|
| 682 | + $column_content = (int)$product['product_stock'] . ' ' . __('unit(s)', 'wpshop'); |
|
| 683 | 683 | break; |
| 684 | 684 | |
| 685 | 685 | case "product_price": |
| 686 | - if( !empty($product['product_price']) ) |
|
| 687 | - $column_content = wpshop_prices::get_product_price( $product, 'price_display', 'complete_sheet'); |
|
| 686 | + if (!empty($product['product_price'])) |
|
| 687 | + $column_content = wpshop_prices::get_product_price($product, 'price_display', 'complete_sheet'); |
|
| 688 | 688 | break; |
| 689 | 689 | |
| 690 | 690 | case "tx_tva": |
| 691 | - if( !empty($product['product_price']) ) |
|
| 692 | - $column_content = number_format($product[$column],2,'.', ' ').' %'; |
|
| 691 | + if (!empty($product['product_price'])) |
|
| 692 | + $column_content = number_format($product[$column], 2, '.', ' ') . ' %'; |
|
| 693 | 693 | break; |
| 694 | 694 | default: |
| 695 | - if ( !empty($product[$column]) ) { |
|
| 695 | + if (!empty($product[$column])) { |
|
| 696 | 696 | $attribute_prices = unserialize(WPSHOP_ATTRIBUTE_PRICES); |
| 697 | - if ( in_array($column, $attribute_prices) ) { |
|
| 698 | - $column_content = number_format($product[$column],2,'.', ' ').' '.wpshop_tools::wpshop_get_currency(); |
|
| 697 | + if (in_array($column, $attribute_prices)) { |
|
| 698 | + $column_content = number_format($product[$column], 2, '.', ' ') . ' ' . wpshop_tools::wpshop_get_currency(); |
|
| 699 | 699 | |
| 700 | 700 | } |
| 701 | 701 | else |
@@ -716,16 +716,16 @@ discard block |
||
| 716 | 716 | * Display a form allowing to create an entity from frontend with a shortcode |
| 717 | 717 | * @param array $shortcode_args The different parameters for the shortocde: the field list for the form, different parameters for the entity to create |
| 718 | 718 | */ |
| 719 | - public static function wpshop_entities_shortcode( $shortcode_args ) { |
|
| 719 | + public static function wpshop_entities_shortcode($shortcode_args) { |
|
| 720 | 720 | global $wpshop_account, $wpdb; |
| 721 | 721 | $output = $form_content = ''; |
| 722 | - $quick_entity_add_button = !empty( $_POST['quick_entity_add_button'] ) ? (int) $_POST['quick_entity_add_button'] : 0; |
|
| 723 | - if ( get_current_user_id() > 0 ) { |
|
| 724 | - if ( !empty( $quick_entity_add_button ) ) { |
|
| 722 | + $quick_entity_add_button = !empty($_POST['quick_entity_add_button']) ? (int)$_POST['quick_entity_add_button'] : 0; |
|
| 723 | + if (get_current_user_id() > 0) { |
|
| 724 | + if (!empty($quick_entity_add_button)) { |
|
| 725 | 725 | $attributes = array(); |
| 726 | - $attribute = !empty($_POST['attribute']) ? (array) $_POST['attribute'] : array(); |
|
| 727 | - foreach ( $attribute as $attribute_type => $attribute ) { |
|
| 728 | - foreach ( $attribute as $attribute_code => $attribute_value ) { |
|
| 726 | + $attribute = !empty($_POST['attribute']) ? (array)$_POST['attribute'] : array(); |
|
| 727 | + foreach ($attribute as $attribute_type => $attribute) { |
|
| 728 | + foreach ($attribute as $attribute_code => $attribute_value) { |
|
| 729 | 729 | $attributes[$attribute_code] = $attribute_value; |
| 730 | 730 | } |
| 731 | 731 | } |
@@ -733,23 +733,23 @@ discard block |
||
| 733 | 733 | $result = wpshop_products::addProduct($title, '', $attributes, 'complete'); |
| 734 | 734 | } |
| 735 | 735 | |
| 736 | - if ( empty($shortcode_args['attribute_set_id']) || empty($shortcode_args['post_type']) ) { |
|
| 736 | + if (empty($shortcode_args['attribute_set_id']) || empty($shortcode_args['post_type'])) { |
|
| 737 | 737 | $output = __('This form page is invalid because no set or type or content is defined. Please contact administrator with this error message', 'wpshop'); |
| 738 | 738 | } |
| 739 | 739 | else { |
| 740 | 740 | $entity_identifier = wpshop_entities::get_entity_identifier_from_code($shortcode_args['post_type']); |
| 741 | 741 | $attribute_set_def = wpshop_attributes_set::getElement($shortcode_args['attribute_set_id'], "'valid'"); |
| 742 | 742 | |
| 743 | - if ( empty($entity_identifier) || empty($attribute_set_def) || ($entity_identifier != $attribute_set_def->entity_id) ) { |
|
| 743 | + if (empty($entity_identifier) || empty($attribute_set_def) || ($entity_identifier != $attribute_set_def->entity_id)) { |
|
| 744 | 744 | $output = __('This form page is invalid because type and set are not linked. Please contact administrator with this error message', 'wpshop'); |
| 745 | 745 | } |
| 746 | 746 | else { |
| 747 | 747 | /** Display wordpress fields */ |
| 748 | - foreach ( explode(', ', $shortcode_args['fields']) as $field_name ) { |
|
| 748 | + foreach (explode(', ', $shortcode_args['fields']) as $field_name) { |
|
| 749 | 749 | $label = ''; |
| 750 | - switch ( $field_name ) { |
|
| 750 | + switch ($field_name) { |
|
| 751 | 751 | case 'post_title': |
| 752 | - switch ( $shortcode_args['post_type'] ) { |
|
| 752 | + switch ($shortcode_args['post_type']) { |
|
| 753 | 753 | case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT: |
| 754 | 754 | $label = __('Product title', 'wpshop'); |
| 755 | 755 | break; |
@@ -761,7 +761,7 @@ discard block |
||
| 761 | 761 | $field_type = 'text'; |
| 762 | 762 | break; |
| 763 | 763 | case 'post_thumbnail': |
| 764 | - switch ( $shortcode_args['post_type'] ) { |
|
| 764 | + switch ($shortcode_args['post_type']) { |
|
| 765 | 765 | case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT: |
| 766 | 766 | $label = __('Product picture', 'wpshop'); |
| 767 | 767 | break; |
@@ -774,7 +774,7 @@ discard block |
||
| 774 | 774 | break; |
| 775 | 775 | } |
| 776 | 776 | |
| 777 | - if ( !empty( $label ) ) { |
|
| 777 | + if (!empty($label)) { |
|
| 778 | 778 | $template_part = 'quick_entity_wp_internal_field_' . $field_type; |
| 779 | 779 | $tpl_component = array(); |
| 780 | 780 | $tpl_component['WP_FIELD_NAME'] = $field_name; |
@@ -807,20 +807,20 @@ discard block |
||
| 807 | 807 | ORDER BY ATT_GROUP.position, ATTR_DET.position" |
| 808 | 808 | , 'yes', 'valid', wpshop_entities::get_entity_identifier_from_code($shortcode_args['post_type']), $shortcode_args['attribute_set_id']); |
| 809 | 809 | $attribute_for_creation = $wpdb->get_results($query); |
| 810 | - foreach ( $attribute_for_creation as $attribute ) { |
|
| 811 | - $attr_field = wpshop_attributes::display_attribute( $attribute->code, 'frontend'/* (is_admin() ? 'admin' : 'frontend') */ ); |
|
| 810 | + foreach ($attribute_for_creation as $attribute) { |
|
| 811 | + $attr_field = wpshop_attributes::display_attribute($attribute->code, 'frontend'/* (is_admin() ? 'admin' : 'frontend') */); |
|
| 812 | 812 | $form_content .= $attr_field['field']; |
| 813 | 813 | } |
| 814 | 814 | |
| 815 | 815 | /** Check if there are extra parameters */ |
| 816 | - if ( !empty( $shortcode_args['extra_element'] ) ) { |
|
| 816 | + if (!empty($shortcode_args['extra_element'])) { |
|
| 817 | 817 | $extra_element = explode(', ', $shortcode_args['extra_element']); |
| 818 | - foreach ( $extra_element as $element) { |
|
| 818 | + foreach ($extra_element as $element) { |
|
| 819 | 819 | $element_def = explode('!#wps#!', $element); |
| 820 | 820 | $element_type = $element_def[0]; |
| 821 | 821 | $element_id = $element_def[1]; |
| 822 | 822 | |
| 823 | - if ( $element_type == WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS ) { |
|
| 823 | + if ($element_type == WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS) { |
|
| 824 | 824 | $form_content .= '<div class="wpshop_entity_address_container">'; |
| 825 | 825 | // $form_content .= $wpshop_account->display_form_fields($element_id, null, 'not'); |
| 826 | 826 | $form_content .= '</div><div class="wpshop_cls"></div>'; |
@@ -833,7 +833,7 @@ discard block |
||
| 833 | 833 | $template_part = 'quick_entity_add_form'; |
| 834 | 834 | $tpl_component = array(); |
| 835 | 835 | $tpl_component['ENTITY_TYPE'] = $shortcode_args['post_type']; |
| 836 | - $tpl_component['ENTITY_ATTRIBUTE_SET_ID'] = !empty( $shortcode_args['attribute_set_id'] ) ? $shortcode_args['attribute_set_id'] : 0; |
|
| 836 | + $tpl_component['ENTITY_ATTRIBUTE_SET_ID'] = !empty($shortcode_args['attribute_set_id']) ? $shortcode_args['attribute_set_id'] : 0; |
|
| 837 | 837 | $tpl_component['NEW_ENTITY_FORM_DETAILS'] = $form_content; |
| 838 | 838 | $tpl_component['ENTITY_QUICK_ADDING_FORM_NONCE'] = wp_create_nonce("wpshop_add_new_entity_ajax_nonce"); |
| 839 | 839 | $tpl_component['ENTITY_QUICK_ADD_BUTTON_TEXT'] = __($shortcode_args['button_text'], 'wpshop'); |
@@ -843,7 +843,7 @@ discard block |
||
| 843 | 843 | $dialog_identifier = 'new_value_for_entity'; |
| 844 | 844 | $dialog_input_identifier = 'wpshop_new_attribute_option_value'; |
| 845 | 845 | ob_start(); |
| 846 | - include(WPSHOP_TEMPLATES_DIR.'admin/add_new_element_dialog.tpl.php'); |
|
| 846 | + include(WPSHOP_TEMPLATES_DIR . 'admin/add_new_element_dialog.tpl.php'); |
|
| 847 | 847 | $tpl_component['DIALOG_BOX'] = ob_get_contents(); |
| 848 | 848 | ob_end_clean(); |
| 849 | 849 | $tpl_component['DIALOG_BOX'] .= '<input type="hidden" name="wpshop_attribute_type_select_code" value="" id="wpshop_attribute_type_select_code" />'; |
@@ -885,14 +885,14 @@ discard block |
||
| 885 | 885 | /** Add the new product */ |
| 886 | 886 | $entity_id = wp_insert_post($entity_args); |
| 887 | 887 | |
| 888 | - do_action( 'wps_entity_more_action' , $entity_id, $attributes); |
|
| 888 | + do_action('wps_entity_more_action', $entity_id, $attributes); |
|
| 889 | 889 | |
| 890 | 890 | /** Update the attribute set id for the current product */ |
| 891 | - if ( !empty($extra_params['attribute_set_id']) ) { |
|
| 891 | + if (!empty($extra_params['attribute_set_id'])) { |
|
| 892 | 892 | $attribute_set_id = $extra_params['attribute_set_id']; |
| 893 | 893 | } |
| 894 | 894 | else { |
| 895 | - $query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE_SET . " WHERE status = %s AND entity_id = %d AND default_set = %s", 'valid', wpshop_entities::get_entity_identifier_from_code($entity_type) , 'yes'); |
|
| 895 | + $query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE_SET . " WHERE status = %s AND entity_id = %d AND default_set = %s", 'valid', wpshop_entities::get_entity_identifier_from_code($entity_type), 'yes'); |
|
| 896 | 896 | $attribute_set_id = $wpdb->get_var($query); |
| 897 | 897 | } |
| 898 | 898 | update_post_meta($entity_id, '_' . $entity_type . '_attribute_set_id', $attribute_set_id); |
@@ -910,7 +910,7 @@ discard block |
||
| 910 | 910 | * |
| 911 | 911 | * @return array The different response element for the request. $result: Boolean representing if creation is OK / $container: Where the result must be placed into output code / $output: The html content to output |
| 912 | 912 | */ |
| 913 | - public static function create_cpt_from_csv_file( $identifier, $custom_file = '' ) { |
|
| 913 | + public static function create_cpt_from_csv_file($identifier, $custom_file = '') { |
|
| 914 | 914 | global $wpdb; |
| 915 | 915 | $output = ''; |
| 916 | 916 | $container = ''; |
@@ -930,47 +930,47 @@ discard block |
||
| 930 | 930 | $custom_post_type_identifier = $wpdb->get_var($query); |
| 931 | 931 | $container = 'wpshop_cpt_' . $identifier; |
| 932 | 932 | |
| 933 | - $file_uri = !empty( $custom_file ) ? $custom_file : WPSHOP_TEMPLATES_DIR . 'default_datas/' . $identifier . '.csv'; |
|
| 934 | - if ( is_file( $file_uri ) && empty($custom_post_type_identifier) ) { |
|
| 933 | + $file_uri = !empty($custom_file) ? $custom_file : WPSHOP_TEMPLATES_DIR . 'default_datas/' . $identifier . '.csv'; |
|
| 934 | + if (is_file($file_uri) && empty($custom_post_type_identifier)) { |
|
| 935 | 935 | $csv_file_default_data = file($file_uri, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
| 936 | 936 | |
| 937 | - $db_field_definition = explode( ";", $csv_file_default_data[0] ); |
|
| 938 | - $db_datas_definition = explode( ";", $csv_file_default_data[1] ); |
|
| 937 | + $db_field_definition = explode(";", $csv_file_default_data[0]); |
|
| 938 | + $db_datas_definition = explode(";", $csv_file_default_data[1]); |
|
| 939 | 939 | |
| 940 | 940 | $has_error = false; |
| 941 | 941 | $errors = array(); |
| 942 | - foreach ( $custom_post_type_default_structure as $field_name => $field_default_value ) { |
|
| 943 | - if ( !in_array( str_replace( 'post_', '', $field_name ) , $db_field_definition ) ) { |
|
| 944 | - if ( $field_name == 'post_name' ) { |
|
| 942 | + foreach ($custom_post_type_default_structure as $field_name => $field_default_value) { |
|
| 943 | + if (!in_array(str_replace('post_', '', $field_name), $db_field_definition)) { |
|
| 944 | + if ($field_name == 'post_name') { |
|
| 945 | 945 | $db_datas_definition[] = $identifier; |
| 946 | - $db_field_definition[] = str_replace( 'post_', '', $field_name ); |
|
| 946 | + $db_field_definition[] = str_replace('post_', '', $field_name); |
|
| 947 | 947 | } |
| 948 | - else if ( $field_default_value == 'mandatory' ) { |
|
| 948 | + else if ($field_default_value == 'mandatory') { |
|
| 949 | 949 | $has_error = true; |
| 950 | 950 | $errors[] = $field_name; |
| 951 | 951 | } |
| 952 | 952 | else { |
| 953 | 953 | $db_datas_definition[] = $field_default_value; |
| 954 | - $db_field_definition[] = str_replace( 'post_', '', $field_name ); |
|
| 954 | + $db_field_definition[] = str_replace('post_', '', $field_name); |
|
| 955 | 955 | } |
| 956 | 956 | } |
| 957 | 957 | } |
| 958 | 958 | |
| 959 | - if ( $has_error ) { |
|
| 959 | + if ($has_error) { |
|
| 960 | 960 | $result = false; |
| 961 | - $output = sprintf( __('You have to fill %s, they are mandatory for custom type creation', 'wpshop'), implode(',', $errors) ); |
|
| 961 | + $output = sprintf(__('You have to fill %s, they are mandatory for custom type creation', 'wpshop'), implode(',', $errors)); |
|
| 962 | 962 | } |
| 963 | 963 | else { |
| 964 | 964 | $custom_post_type_def = array(); |
| 965 | - foreach ( $db_field_definition as $field_position => $field_name ) { |
|
| 965 | + foreach ($db_field_definition as $field_position => $field_name) { |
|
| 966 | 966 | $custom_post_type_def['post_' . $field_name] = $db_datas_definition[$field_position]; |
| 967 | 967 | } |
| 968 | - $new_custom_post_type = wp_insert_post( $custom_post_type_def ); |
|
| 969 | - if ( is_int($new_custom_post_type) && !empty($new_custom_post_type) ) { |
|
| 968 | + $new_custom_post_type = wp_insert_post($custom_post_type_def); |
|
| 969 | + if (is_int($new_custom_post_type) && !empty($new_custom_post_type)) { |
|
| 970 | 970 | $result = true; |
| 971 | 971 | } |
| 972 | 972 | |
| 973 | - $check_cpt = wpshop_entities::check_default_custom_post_type( $identifier, array(), $result, $custom_file ); |
|
| 973 | + $check_cpt = wpshop_entities::check_default_custom_post_type($identifier, array(), $result, $custom_file); |
|
| 974 | 974 | $output = $check_cpt[1]; |
| 975 | 975 | } |
| 976 | 976 | } |
@@ -986,20 +986,20 @@ discard block |
||
| 986 | 986 | * |
| 987 | 987 | * @return array The different response element for the request. $has_error: A boolean result of request / $output: The complete html output for custom post type check / $tpl_componene: A mode complete list of element of templates |
| 988 | 988 | */ |
| 989 | - public static function check_default_custom_post_type( $identifier, $tpl_component ) { |
|
| 989 | + public static function check_default_custom_post_type($identifier, $tpl_component) { |
|
| 990 | 990 | global $wpdb; |
| 991 | 991 | $has_error = false; |
| 992 | 992 | |
| 993 | 993 | /** Check if custom post type exists */ |
| 994 | 994 | $query = $wpdb->prepare("SELECT post_title FROM " . $wpdb->posts . " WHERE post_name = %s", $identifier); |
| 995 | 995 | $custom_post_type_title = $wpdb->get_var($query); |
| 996 | - if ( !empty($custom_post_type_title) ) { |
|
| 996 | + if (!empty($custom_post_type_title)) { |
|
| 997 | 997 | $tpl_component['CUSTOM_POST_TYPE_IDENTIFIER'] = '<img class="wpshop_tools_check_icon no_error" src="' . WPSHOP_MEDIAS_ICON_URL . 'informations/success_s.png" /> ' . $custom_post_type_title . ' (' . $identifier . ')'; |
| 998 | 998 | $tpl_component['TOOLS_CUSTOM_POST_TYPE_CONTAINER_CLASS'] = ' no_error'; |
| 999 | 999 | $tpl_component['CUSTOM_POST_TYPE_DEFAULT_ATTRIBUTES'] = ''; |
| 1000 | 1000 | $template_part = 'wpshop_admin_tools_default_datas_check_main_element_content_no_error'; |
| 1001 | 1001 | |
| 1002 | - $attributes_for_cpt = wpshop_entities::check_default_cpt_attributes( $identifier, $tpl_component, $has_error ); |
|
| 1002 | + $attributes_for_cpt = wpshop_entities::check_default_cpt_attributes($identifier, $tpl_component, $has_error); |
|
| 1003 | 1003 | $has_error = $attributes_for_cpt[0]; |
| 1004 | 1004 | $tpl_component['CUSTOM_POST_TYPE_DEFAULT_ATTRIBUTES'] = $attributes_for_cpt[1]; |
| 1005 | 1005 | } |
@@ -1024,39 +1024,39 @@ discard block |
||
| 1024 | 1024 | * |
| 1025 | 1025 | * @return array The different response element for the request. $has_error: A boolean information for request result / $output: The complete html output for attribute check |
| 1026 | 1026 | */ |
| 1027 | - public static function check_default_cpt_attributes( $identifier, $tpl_component, $has_error, $custom_file = '' ) { |
|
| 1027 | + public static function check_default_cpt_attributes($identifier, $tpl_component, $has_error, $custom_file = '') { |
|
| 1028 | 1028 | global $wpdb, $attribute_displayed_field; |
| 1029 | 1029 | $output = ''; |
| 1030 | 1030 | |
| 1031 | - $cpt_attributes_file_uri = !empty( $custom_file ) ? $custom_file : WPSHOP_TEMPLATES_DIR . 'default_datas/' . $identifier . '-attributes.csv'; |
|
| 1032 | - if ( is_file( $cpt_attributes_file_uri ) ) { |
|
| 1031 | + $cpt_attributes_file_uri = !empty($custom_file) ? $custom_file : WPSHOP_TEMPLATES_DIR . 'default_datas/' . $identifier . '-attributes.csv'; |
|
| 1032 | + if (is_file($cpt_attributes_file_uri)) { |
|
| 1033 | 1033 | /** Read lines into file defining default datas */ |
| 1034 | 1034 | $csv_file_default_data = file($cpt_attributes_file_uri, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
| 1035 | - if ( !empty($csv_file_default_data) ) { |
|
| 1035 | + if (!empty($csv_file_default_data)) { |
|
| 1036 | 1036 | $header_line = explode(';', $csv_file_default_data[0]); |
| 1037 | 1037 | unset($csv_file_default_data[0]); |
| 1038 | 1038 | $code_column = null; |
| 1039 | 1039 | $available_columns = array(); |
| 1040 | - foreach ( $header_line as $column_key => $column_value ) { |
|
| 1041 | - if ( $column_value == 'code' ) { |
|
| 1040 | + foreach ($header_line as $column_key => $column_value) { |
|
| 1041 | + if ($column_value == 'code') { |
|
| 1042 | 1042 | $code_column = $column_key; |
| 1043 | 1043 | // $available_columns[$column_value] = $column_key; |
| 1044 | 1044 | } |
| 1045 | - else if ( in_array( $column_value, array('frontend_label')/* $attribute_displayed_field */ ) ) { |
|
| 1045 | + else if (in_array($column_value, array('frontend_label')/* $attribute_displayed_field */)) { |
|
| 1046 | 1046 | $available_columns[$column_value] = $column_key; |
| 1047 | 1047 | } |
| 1048 | 1048 | } |
| 1049 | 1049 | |
| 1050 | 1050 | /** Read the complete file content */ |
| 1051 | 1051 | $attribute_ok = $attribute_not_ok = ' '; |
| 1052 | - foreach ( $csv_file_default_data as $line_index => $line_content ) { |
|
| 1052 | + foreach ($csv_file_default_data as $line_index => $line_content) { |
|
| 1053 | 1053 | $line_contents = explode(';', $line_content); |
| 1054 | 1054 | $query = $wpdb->prepare("SELECT id, frontend_label FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code = %s AND entity_id = %d", $line_contents[$code_column], wpshop_entities::get_entity_identifier_from_code($identifier)); |
| 1055 | - $attribute = $wpdb->get_row( $query ); |
|
| 1056 | - if ( !empty($line_contents) ) { |
|
| 1057 | - foreach ( $line_contents as $line_column => $line_column_value ) { |
|
| 1058 | - if ( in_array( $line_column, $available_columns ) ) { |
|
| 1059 | - if ( !empty($attribute) ) { |
|
| 1055 | + $attribute = $wpdb->get_row($query); |
|
| 1056 | + if (!empty($line_contents)) { |
|
| 1057 | + foreach ($line_contents as $line_column => $line_column_value) { |
|
| 1058 | + if (in_array($line_column, $available_columns)) { |
|
| 1059 | + if (!empty($attribute)) { |
|
| 1060 | 1060 | $attribute_ok .= $attribute->frontend_label . ', '; |
| 1061 | 1061 | } |
| 1062 | 1062 | else { |
@@ -1067,18 +1067,18 @@ discard block |
||
| 1067 | 1067 | } |
| 1068 | 1068 | } |
| 1069 | 1069 | } |
| 1070 | - $attribute_not_ok = substr( $attribute_not_ok, 2, -2 ); |
|
| 1071 | - if ( !empty($attribute_not_ok) ) { |
|
| 1072 | - $output .= wpshop_display::display_template_element('wpshop_admin_tools_default_datas_check_main_element_content_attributes_error', array_merge( $tpl_component, array( 'CUSTOM_POST_TYPE_DEFAULT_ATTRIBUTES_LIST' => $attribute_not_ok )), array(), 'admin'); |
|
| 1070 | + $attribute_not_ok = substr($attribute_not_ok, 2, -2); |
|
| 1071 | + if (!empty($attribute_not_ok)) { |
|
| 1072 | + $output .= wpshop_display::display_template_element('wpshop_admin_tools_default_datas_check_main_element_content_attributes_error', array_merge($tpl_component, array('CUSTOM_POST_TYPE_DEFAULT_ATTRIBUTES_LIST' => $attribute_not_ok)), array(), 'admin'); |
|
| 1073 | 1073 | } |
| 1074 | - $attribute_ok = substr( $attribute_ok, 2, -2 ); |
|
| 1075 | - if ( !empty($attribute_ok) ) { |
|
| 1076 | - $output .= wpshop_display::display_template_element('wpshop_admin_tools_default_datas_check_main_element_content_attributes_no_error', array_merge( $tpl_component, array( 'CUSTOM_POST_TYPE_DEFAULT_ATTRIBUTES_LIST' => $attribute_ok )), array(), 'admin'); |
|
| 1074 | + $attribute_ok = substr($attribute_ok, 2, -2); |
|
| 1075 | + if (!empty($attribute_ok)) { |
|
| 1076 | + $output .= wpshop_display::display_template_element('wpshop_admin_tools_default_datas_check_main_element_content_attributes_no_error', array_merge($tpl_component, array('CUSTOM_POST_TYPE_DEFAULT_ATTRIBUTES_LIST' => $attribute_ok)), array(), 'admin'); |
|
| 1077 | 1077 | } |
| 1078 | 1078 | } |
| 1079 | 1079 | } |
| 1080 | 1080 | |
| 1081 | - return array( $has_error, $output ); |
|
| 1081 | + return array($has_error, $output); |
|
| 1082 | 1082 | } |
| 1083 | 1083 | |
| 1084 | 1084 | /** |
@@ -1088,60 +1088,60 @@ discard block |
||
| 1088 | 1088 | * |
| 1089 | 1089 | * @return array The different response element for the request. $result: Boolean representing if creation is OK / $container: Where the result must be placed into output code / $output: The html content to output |
| 1090 | 1090 | */ |
| 1091 | - public static function create_cpt_attributes_from_csv_file( $identifier, $custom_file = '' ) { |
|
| 1091 | + public static function create_cpt_attributes_from_csv_file($identifier, $custom_file = '') { |
|
| 1092 | 1092 | global $wpdb; |
| 1093 | 1093 | |
| 1094 | 1094 | $output = $container = ''; |
| 1095 | 1095 | $result = true; |
| 1096 | 1096 | $container = 'wpshop_cpt_' . $identifier . ' ul.wpshop_tools_default_datas_repair_attribute_container'; |
| 1097 | - $excluded_column = array( 'available_values' ); |
|
| 1097 | + $excluded_column = array('available_values'); |
|
| 1098 | 1098 | |
| 1099 | - $file_uri = !empty( $custom_file ) ? $custom_file : WPSHOP_TEMPLATES_DIR . 'default_datas/' . $identifier . '-attributes.csv'; |
|
| 1100 | - if ( is_file( $file_uri ) ) { |
|
| 1099 | + $file_uri = !empty($custom_file) ? $custom_file : WPSHOP_TEMPLATES_DIR . 'default_datas/' . $identifier . '-attributes.csv'; |
|
| 1100 | + if (is_file($file_uri)) { |
|
| 1101 | 1101 | $entity_id = wpshop_entities::get_entity_identifier_from_code($identifier); |
| 1102 | 1102 | $csv_file_default_data = file($file_uri, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
| 1103 | 1103 | |
| 1104 | - $db_field_definition = explode( ";", $csv_file_default_data[0] ); |
|
| 1104 | + $db_field_definition = explode(";", $csv_file_default_data[0]); |
|
| 1105 | 1105 | $code_column = null; |
| 1106 | - foreach ( $db_field_definition as $column_index => $column_name ) { |
|
| 1107 | - if ( $column_name == 'code' ) { |
|
| 1106 | + foreach ($db_field_definition as $column_index => $column_name) { |
|
| 1107 | + if ($column_name == 'code') { |
|
| 1108 | 1108 | $code_column = $column_index; |
| 1109 | 1109 | continue; |
| 1110 | 1110 | } |
| 1111 | 1111 | } |
| 1112 | 1112 | unset($csv_file_default_data[0]); |
| 1113 | 1113 | |
| 1114 | - if ( !empty($code_column) || ($code_column == 0) ) { |
|
| 1115 | - foreach ( $csv_file_default_data as $line_index => $line_content ) { |
|
| 1116 | - $attribute_definition = explode( ";", $line_content ); |
|
| 1117 | - $query = $wpdb->prepare( "SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code = %s AND entity_id = %d", $attribute_definition[$code_column], $entity_id); |
|
| 1114 | + if (!empty($code_column) || ($code_column == 0)) { |
|
| 1115 | + foreach ($csv_file_default_data as $line_index => $line_content) { |
|
| 1116 | + $attribute_definition = explode(";", $line_content); |
|
| 1117 | + $query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code = %s AND entity_id = %d", $attribute_definition[$code_column], $entity_id); |
|
| 1118 | 1118 | $attribute_identifier = $wpdb->get_var($query); |
| 1119 | 1119 | |
| 1120 | - if ( empty($attribute_identifier) ) { |
|
| 1120 | + if (empty($attribute_identifier)) { |
|
| 1121 | 1121 | $attribute_def = array(); |
| 1122 | 1122 | $attribute_values = $default_value = null; |
| 1123 | - foreach ( $db_field_definition as $column_index => $column_name ) { |
|
| 1123 | + foreach ($db_field_definition as $column_index => $column_name) { |
|
| 1124 | 1124 | $column_name = trim($column_name); |
| 1125 | - if ( !empty($column_name) && !in_array($column_name, $excluded_column) ) { |
|
| 1125 | + if (!empty($column_name) && !in_array($column_name, $excluded_column)) { |
|
| 1126 | 1126 | $column_value = $attribute_definition[$column_index]; |
| 1127 | - switch ( $column_name ) { |
|
| 1127 | + switch ($column_name) { |
|
| 1128 | 1128 | case 'frontend_label': |
| 1129 | - $column_value = __( $column_value, 'wpshop' ); |
|
| 1129 | + $column_value = __($column_value, 'wpshop'); |
|
| 1130 | 1130 | break; |
| 1131 | 1131 | } |
| 1132 | - $attribute_def[$column_name] = ( !empty($attribute_definition[$column_index]) ) ? $column_value : ''; |
|
| 1132 | + $attribute_def[$column_name] = (!empty($attribute_definition[$column_index])) ? $column_value : ''; |
|
| 1133 | 1133 | } |
| 1134 | 1134 | else { |
| 1135 | - switch ( $column_name ) { |
|
| 1135 | + switch ($column_name) { |
|
| 1136 | 1136 | case 'available_values': |
| 1137 | 1137 | $attribute_values = $attribute_definition[$column_index]; |
| 1138 | 1138 | break; |
| 1139 | 1139 | } |
| 1140 | 1140 | } |
| 1141 | 1141 | |
| 1142 | - switch ( $column_name ) { |
|
| 1142 | + switch ($column_name) { |
|
| 1143 | 1143 | case 'default_value': |
| 1144 | - $default_value = __( $attribute_definition[$column_index], 'wpshop' ); |
|
| 1144 | + $default_value = __($attribute_definition[$column_index], 'wpshop'); |
|
| 1145 | 1145 | break; |
| 1146 | 1146 | } |
| 1147 | 1147 | } |
@@ -1150,14 +1150,14 @@ discard block |
||
| 1150 | 1150 | $last_attribute_id = $wpdb->insert_id; |
| 1151 | 1151 | |
| 1152 | 1152 | /** Create values for select element */ |
| 1153 | - if ( !empty($attribute_values) ) { |
|
| 1154 | - $list_of_values_to_create = explode( ',', $attribute_values ); |
|
| 1155 | - if ( !empty($list_of_values_to_create) ) { |
|
| 1156 | - foreach ( $list_of_values_to_create as $value ) { |
|
| 1157 | - $value_element = explode( '!:!:!', $value); |
|
| 1158 | - $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'attribute_id' => $last_attribute_id, 'label' => __( $value_element[0], 'wpshop' ), 'value' => __( (!empty($value_element[1]) ? $value_element[1] : strtolower($value_element[0]) ), 'wpshop' ))); |
|
| 1159 | - |
|
| 1160 | - if ( $default_value == (!empty($value_element[1]) ? $value_element[1] : strtolower($value_element[0])) ) { |
|
| 1153 | + if (!empty($attribute_values)) { |
|
| 1154 | + $list_of_values_to_create = explode(',', $attribute_values); |
|
| 1155 | + if (!empty($list_of_values_to_create)) { |
|
| 1156 | + foreach ($list_of_values_to_create as $value) { |
|
| 1157 | + $value_element = explode('!:!:!', $value); |
|
| 1158 | + $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'attribute_id' => $last_attribute_id, 'label' => __($value_element[0], 'wpshop'), 'value' => __((!empty($value_element[1]) ? $value_element[1] : strtolower($value_element[0])), 'wpshop'))); |
|
| 1159 | + |
|
| 1160 | + if ($default_value == (!empty($value_element[1]) ? $value_element[1] : strtolower($value_element[0]))) { |
|
| 1161 | 1161 | $wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('last_update_date' => current_time('mysql', 0), 'default_value' => $wpdb->insert_id), array('id' => $last_attribute_id, 'default_value' => $default_value)); |
| 1162 | 1162 | } |
| 1163 | 1163 | } |
@@ -1169,7 +1169,7 @@ discard block |
||
| 1169 | 1169 | } |
| 1170 | 1170 | } |
| 1171 | 1171 | |
| 1172 | - $check_cpt = wpshop_entities::check_default_cpt_attributes( $identifier, array(), false, $custom_file ); |
|
| 1172 | + $check_cpt = wpshop_entities::check_default_cpt_attributes($identifier, array(), false, $custom_file); |
|
| 1173 | 1173 | $output = $check_cpt[1]; |
| 1174 | 1174 | |
| 1175 | 1175 | return array($result, $container, $output); |