Changeset 1576226
- Timestamp:
- 01/17/2017 08:10:37 AM (9 years ago)
- Location:
- woo-layout-editor/trunk
- Files:
-
- 4 edited
-
Readme.txt (modified) (4 diffs)
-
css/woo_layout_editor.css (modified) (3 diffs)
-
screenshot-1.jpg (modified) (previous)
-
woo-product-editor.php (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
woo-layout-editor/trunk/Readme.txt
r1536428 r1576226 2 2 3 3 Contributors: Izack Lesher 4 Tags: woocommerce, editor, customize, customizer, customizing, modify, modifying, layout, drag, drop, product, shop4 Tags: woocommerce, customize, customization, customizer, modify, modification, editor, gui, drag and drop 5 5 Requires at least: 4.1 6 6 Tested up to: 4.6.1 7 Stable tag: 1. 4.87 Stable tag: 1.5.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 33 33 34 34 == What are the common uses of the plugin? 35 35 36 Adding any Html markup to the product page and to the shop page. 36 37 Dropping the prices in the product page and in the shop will convert the shop into a catalog. 37 38 Dropping the prices the shop will focus the visitor to the products and will introduce prices … … 56 57 57 58 Not at all. The plugin follows WooCmmerce recommendations that prefer using hooks and thus doesn't touch the theme. 59 60 == After using the Link inside the Product layout the original product hyperlink doesn't work? 61 62 Using Link in the Product layout actually creates a second hyperlink inside the product list element. 63 This may end up with overriding the original hyperlink. In this case use any cutsom content without a link. 58 64 59 65 == Why is'n there an option to edit other pages like checkout == … … 66 72 67 73 == Changelog == 68 = = 1.4.8=69 Fixing bugs 70 = =1.4.7 =71 Modifytags74 = 1.5.0 = 75 Add Custom Content 76 = 1.4.7 = 77 Add tags 72 78 = 1.4.6 = 73 79 Css update -
woo-layout-editor/trunk/css/woo_layout_editor.css
r1526769 r1576226 1 2 1 .sortable-table{ 3 2 float:left; … … 23 22 float:left; 24 23 } 25 #shop-general , #shop-products {26 width: 50%;27 float: left;28 }29 24 30 25 .defualt-push-button{ … … 60 55 } 61 56 62 57 /* builder css */ 58 #builder-div-product .ul-builder { 59 margin: 100px; 60 } 61 #builder-div-shop-products .ul-builder { 62 margin: 100px; 63 } 64 65 #builder-div-shop .ul-builder { 66 margin: 100px; 67 } 68 69 70 textarea.html-textarea { 71 height: 10em; 72 width: 10em; 73 } 74 h6#html-class { 75 margin-bottom: 0; 76 } 77 textarea#html-class { 78 height: 1.5em; 79 width: 8em; 80 } 81 82 /* builder div and its elements */ 83 84 .sortable-table{ 85 float:left; 86 } 87 88 #sortable1, #sortable2, #sortable_shop1, #sortable_shop2 , #sortable_shop1pr, #sortable_shop2pr { 89 border: 1px solid #eee; 90 width: 142px; 91 min-height: 20px; 92 list-style-type: none; 93 margin: 0; 94 padding: 5px 0 0 0; 95 float: left; 96 margin-right: 10px; 97 } 98 #sortable1 li, #sortable2 li, #sortable_shop1 li, #sortable_shop2 li, #sortable_shop1pr li, #sortable_shop2pr li { 99 margin: 0 5px 5px 5px; 100 padding: 5px; 101 font-size: 1.2em; 102 width: 120px; 103 } 104 .connectedSortable{ 105 float:left; 106 } 107 108 .defualt-push-button{ 109 float:left; 110 width: 30%; 111 } 112 div#seialize-div { 113 float: left; 114 } 115 div#seialize-div-shop { 116 float: left; 117 } 118 div#seialize-div-shop-products { 119 float: left; 120 } 121 122 h6.h6-class { 123 font-size: xx-small; 124 margin: initial; 125 } 126 127 #serilization-layers-shop-products, #serilization-layers-shop, #serialize-layers{ 128 display:none; 129 } 130 /* indicate in red that here come the product layout */ 131 ul b{ 132 color:red; 133 } 134 ul li:hover { 135 cursor:move; 136 } 137 ul li.button:hover { 138 cursor: move; 139 } 140 h2.hndle.ui-sortable-handle { 141 pointer-events: none; 142 } 143 .wp-core-ui .button-link { 144 float:left; 145 } 146 147 /* builder css */ 148 #builder-div-product .ul-builder { 149 margin: 100px; 150 } 151 #builder-div-shop-products .ul-builder { 152 margin: 100px; 153 } 154 #builder-div-shop .ul-builder { 155 margin: 100px; 156 } 157 158 textarea.html-textarea { 159 height: 10em; 160 width: 10em; 161 } 162 h6#html-class { 163 margin-bottom: 0; 164 } 165 textarea#html-class { 166 height: 1.5em; 167 width: 8em; 168 } 169 170 /* builder div and its elements */ 171 #builder-div-product, #builder-div-shop-products ,#builder-div-shop{ 172 width:70%; 173 margin:10px; 174 } 175 #builder-div-product .ul-builder { 176 margin: 10px; 177 margin-top: 0; 178 } 179 #builder-div-shop-products .ul-builder { 180 margin: 10px; 181 margin-top: 0; 182 } 183 #builder-div-shop .ul-builder { 184 margin: 10px; 185 margin-top: 0; 186 } 187 input.button-style { 188 height: 1.5em; 189 } 190 191 #builder-div-product .ul-builder { 192 margin: 10px; 193 margin-top: 0; 194 } 195 #builder-div-shop-products .ul-builder { 196 margin: 10px; 197 margin-top: 0; 198 } 199 #builder-div-shop .ul-builder { 200 margin: 10px; 201 margin-top: 0; 202 } 203 input.button-style { 204 height: 1.5em; 205 } 206 207 div#product-layout { 208 position: relative:; 209 } 210 div#shop-products { 211 position: relative:; 212 } 213 214 #builder-div-product, #builder-div-shop-products, #builder-div-shop { 215 position: absolute; 216 left:30%; 217 } 218 219 #builder-div-product .ul-builder-style { 220 margin-top: 0; 221 } 222 #builder-div-shop-products .ul-builder-style { 223 margin-top: 0; 224 } 225 #builder-div-shop .ul-builder-style { 226 margin-top: 0; 227 } 228 #builder-div-product .ul-builder { 229 margin: 10px; 230 margin-top: 0; 231 height: 400px; 232 } 233 #builder-div-shop-products .ul-builder { 234 margin: 10px; 235 margin-top: 0; 236 height: 400px; 237 } 238 #builder-div-shop .ul-builder { 239 margin: 10px; 240 margin-top: 0; 241 height: 400px; 242 } 243 #builder-div-product, #builder-div-shop-products, #builder-div-shop { 244 position: absolute; 245 left: 30%; 246 width: 50%; 247 display: inline-flex; 248 } 249 250 #builder-div-product .ul-builder-link { 251 margin-top: 0; 252 } 253 #builder-div-shop-products .ul-builder-link { 254 margin-top: 0; 255 } 256 #builder-div-shop .ul-builder-link { 257 margin-top: 0; 258 } 259 260 #builder-div-product, #builder-div-shop-products, #builder-div-shop { 261 position: absolute; 262 left: 30%; 263 width: 50%; 264 top: 120px; 265 } 266 267 .tables h5 { 268 position: absolute; 269 left: 32%; 270 width: 50%; 271 display: inline-flex; 272 margin-top: -10px; 273 } 274 275 #builder-div-product .ul-builder-class { 276 margin-top: 0; 277 } 278 279 #builder-div-shop-products .ul-builder-class { 280 margin-top: 0; 281 } 282 283 #builder-div-shop .ul-builder-class { 284 margin-top: 0; 285 } 286 287 /* just to unhide hidden boxes for debugging */ 288 289 #serilization-layers-shop-products, #serilization-layers-shop, #serialize-layers{ 290 display:block; 291 } 292 293 #builder-div-product li { 294 margin-bottom: 0; 295 } 296 297 #builder-div-shop-products li { 298 margin-bottom: 0; 299 } 300 #builder-div-shop li { 301 margin-bottom: 0; 302 } 303 304 305 /* css for shop */ 306 307 308 div#builder-div-shop { 309 float: left; 310 } 311 312 div#builder-div-shop ul { 313 float: left; 314 } 315 316 /* for the button link etyling */ 317 .wp-core-ui .button-link{ 318 /* margin: 1px; */ 319 padding: 3px 5px; 320 border: 1px solid #ddd; 321 } 322 323 /* zeroing all margins arround all buttons */ 324 input { 325 margin:0; 326 } 327 328 /* expand markup teatare beyond parent left border */ 329 textarea.textarea-markup-id { 330 /* margin-right: -200px !important; */ 331 position: absolute; 332 width: 70%; 333 height: 50%; 334 } 335 336 .tables h5 { 337 position: absolute; 338 left: 32%; 339 width: 50%; 340 display: inline-flex; 341 margin-top: 70px; 342 font-size: 1.2em; 343 } 344 345 input#serialize-layers, input#serialize-layers-product-builder, 346 input#serilization-layers-shop, input#serialize-layers-shop-builder, 347 input#serilization-layers-shop-products, input#serialize-layers-shop-products-builder { 348 display: none; 349 } 350 -
woo-layout-editor/trunk/woo-product-editor.php
r1536428 r1576226 4 4 * Plugin URI: http://www.triplebit.com/myplugins/woo-layout-editor.zip 5 5 * Description: Page/Shop Layout Editor 6 * Version: 1. 4.86 * Version: 1.5.0 7 7 * Author: Izac Lesher 8 8 * Author URI: http://itziklesher.com … … 19 19 global $options_page; 20 20 21 22 $html_builder =""; 21 23 $options = get_option( 'woolayedtil_options' ); 22 24 … … 33 35 $new_options['serialization_stack_shop_products'] = "idshoppr[]=1&idshoppr[]=2&idshoppr[]=3&idshoppr[]=4&idshoppr[]=5&idshoppr[]=6"; 34 36 $new_options['serialization_stack'] = "id[]=1&id[]=2&id[]=3&id[]=4&id[]=5&id[]=6&id[]=7&id[]=8&id[]=9&id[]=10&id[]=11&id[]=12"; 37 $new_options['serialization_stack_product_builder'] = "here comse serialization_stack_product_builder"; 38 $new_options['serialization_stack_shop_products_builder'] = "here comse serialization_stack_shop_products_builder"; 39 $new_options['serialization_stack_shop_builder'] = "here comse serialization_stack_shop_builder"; 35 40 $new_options['version'] = "1.4"; 36 41 add_option( 'woolayedtil_options', $new_options ); 37 42 } else { 38 43 $existing_options = get_option( 'woolayedtil_options' ); 39 if ( $existing_options['version'] < 1. 4) {40 $existing_options['version'] = "1. 4";44 if ( $existing_options['version'] < 1.5 ) { 45 $existing_options['version'] = "1.5.0"; 41 46 update_option( 'woolayedtil_options', $existing_options ); 42 47 } … … 133 138 if(!$('div#Shop_Layout_Editor_Meta_Box').hasClass('closed')){ 134 139 // calculate height according to ul height 135 if ( ($("#sortable_shop1").height() + 70) > $("#sortable_shop2").height())136 $('div#Shop_Layout_Editor_Meta_Box').height($("#sortable_shop1").height() + 140);140 if ( ($("#sortable_shop1").height() + 70) > $("#sortable_shop2").height()) 141 $('div#Shop_Layout_Editor_Meta_Box').height($("#sortable_shop1").height() + 140); 137 142 else 138 143 $('div#Shop_Layout_Editor_Meta_Box').height($("#sortable_shop2").height() + 70); … … 151 156 else{ 152 157 //$('div#Shop_Layout_Editor_Meta_Box').height(900); 158 /* 153 159 shtrudel_count = $('#serialize-layers').val().split("&").length-1; 154 160 if (shtrudel_count >= 4)// if yes than we calculate according trash box … … 156 162 else 157 163 $('div#Shop_Layout_Editor_Meta_Box').height((9 - (shtrudel_count + 1)) * 80); 158 $('div#Shop_Layout_Editor_Meta_Box').height(localStorage.getItem('shop_meta_box_height')); 164 */ 165 $('div#Shop_Layout_Editor_Meta_Box').height(localStorage.getItem('shop_meta_box_height')); 166 167 $('div#Shop_Layout_Editor_Meta_Box').height(localStorage.getItem('shop_meta_box_height')); 159 168 } 160 169 }); 161 170 171 // same for Shop Products Editor 172 173 // takes care in Refresh and in Submit 174 if(!$('div#Shop_Products_Layout_Editor_Meta_Box').hasClass('closed')){ 175 // calculate height according to ul height 176 if ( ($("#sortable_shop1pr").height() + 70) > $("#sortable_shop2pr").height()) 177 $('div#Shop_Products_Layout_Editor_Meta_Box').height($("#sortable_shop1pr").height() + 140); 178 else 179 $('div#Shop_Products_Layout_Editor_Meta_Box').height($("#sortable_shop2pr").height() + 70); 180 // get the height here since checked later in order to choose the most heigh in the shop meta box 181 shop_products_meta_box_height_general = $('div#Shop_Products_Layout_Editor_Meta_Box').height(); 182 localStorage.setItem('shop_products_meta_box_height',$('div#Shop_Products_Layout_Editor_Meta_Box').height()); 183 184 }// if(!$('div#Shop_Products_Layout_Editor_Meta_Box').hasClass('closed')){ 185 else 186 $('div#Shop_Products_Layout_Editor_Meta_Box').height(''); 187 188 // in case we toggle with the right button 189 $('div#Shop_Products_Layout_Editor_Meta_Box button.handlediv.button-link').click(function(){ 190 if(!$('div#Shop_Products_Layout_Editor_Meta_Box').hasClass('closed')) 191 $('div#Shop_Products_Layout_Editor_Meta_Box').height(''); 192 else{ 193 //$('div#Shop_Products_Layout_Editor_Meta_Box').height(900); 194 shtrudel_count = $('#serilization-layers-shop-products').val().split("&").length-1; 195 if (shtrudel_count >= 4)// if yes than we calculate according trash box 196 $('div#Shop_Products_Layout_Editor_Meta_Box').height((shtrudel_count + 1) * 80); 197 else 198 $('div#Shop_Products_Layout_Editor_Meta_Box').height((9 - (shtrudel_count + 1)) * 80); 199 $('div#Shop_Products_Layout_Editor_Meta_Box').height(localStorage.getItem('shop_products_meta_box_height')); 200 } 201 }); 202 203 204 162 205 // postboxes setup 163 206 postboxes.add_postbox_toggles( '<?php echo $options_page; ?>' ); … … 208 251 } 209 252 foreach ( array( 'serialization_stack' ) as $option_name ) { 253 if ( isset( $_POST[$option_name] ) ) { 254 $options[$option_name] = sanitize_text_field($_POST[$option_name]); 255 } 256 } 257 258 foreach ( array( 'serialization_stack_product_builder' ) as $option_name ) { 259 if ( isset( $_POST[$option_name] ) ) { 260 $options[$option_name] = sanitize_text_field($_POST[$option_name]); 261 } 262 } 263 foreach ( array( 'serialization_stack_shop_products_builder' ) as $option_name ) { 264 if ( isset( $_POST[$option_name] ) ) { 265 $options[$option_name] = sanitize_text_field($_POST[$option_name]); 266 } 267 } 268 foreach ( array( 'serialization_stack_shop_builder' ) as $option_name ) { 210 269 if ( isset( $_POST[$option_name] ) ) { 211 270 $options[$option_name] = sanitize_text_field($_POST[$option_name]); … … 263 322 $options_page, 'normal', 'core' ); 264 323 324 add_meta_box( 'Shop_Products_Layout_Editor_Meta_Box', 325 'Shop Products Layout Editor', 'woolayedtil_Shop_Products_Layout_Editor_Meta_Box', 326 $options_page, 'normal', 'core' ); 327 265 328 add_meta_box( 'Product_layout_Editor_Meta_Box', 266 329 'Product Layout Editor', 'woolayedtil_Product_layout_Editor_Meta_Box', 267 330 $options_page, 'normal', 'core' ); 268 331 269 // Tabs and their content270 //add_meta_box( 'tabs_meta_box',271 // 'Tabs', 'tabs_meta_box',272 // $options_page, 'normal', 'core' );273 274 332 } 275 333 … … 300 358 wp_enqueue_script( 'jquery-ui-draggable' ); 301 359 wp_enqueue_script( 'jquery-ui-sortable' ); 302 wp_enqueue_script( 'woolayedtil_dropable_js',plugins_url( './js/dropable.js' , __FILE__ )); 360 wp_enqueue_script( 'woolayedtil_templates_js',plugins_url( './js/templates.js' , __FILE__ )); 361 wp_enqueue_script( 'woolayedtil_shop_js',plugins_url( './js/shop.js' , __FILE__ )); 362 wp_enqueue_script( 'woolayedtil_shopproducts_js',plugins_url( './js/shop-products.js' , __FILE__ )); 363 wp_enqueue_script( 'woolayedtil_product_js',plugins_url( './js/product.js' , __FILE__ )); 303 364 wp_enqueue_style( 'woolayedtil_sortable_css',plugins_url( './css/woo_layout_editor.css' , __FILE__ )); 304 wp_localize_script('woolayedtil_dropable_js', 'objectFromPhp2', array( 365 wp_enqueue_style( 'woolayedtil_fontaesome_css',plugins_url( './font-awesome/css/font-awesome.css' , __FILE__ )); 366 wp_localize_script('woolayedtil_product_js', 'objectFromPhp2', array( 305 367 'sortable_option' => $options['serialization_stack'])); 306 wp_localize_script('woolayedtil_ dropable_js', 'objectFromPhpShop2', array(368 wp_localize_script('woolayedtil_shop_js', 'objectFromPhpShop2', array( 307 369 'sortable_option_shop' => $options['serialization_stack_shop'])); 308 wp_localize_script('woolayedtil_ dropable_js', 'objectFromPhpShop2pr', array(370 wp_localize_script('woolayedtil_shopproducts_js', 'objectFromPhpShop2pr', array( 309 371 'sortable_option_shop_products' => $options['serialization_stack_shop_products'])); 310 372 … … 315 377 316 378 317 function woolayedtil_Shop_Layout_Editor( $options ) 318 { ?> 319 320 <div id="shop-general"> 321 <h6 class="h6-class">Shop General Layout</h6> 322 <ul id="sortable_shop1" class="connectedSortable"> 323 <li id = "idshop_1"> 1 Output Content Wrapper</li> 324 <li id = "idshop_2"> 2 Breadcrumb</li> 325 <li id = "idshop_3"> 3 Taxonomy Archive Description</li> 326 <li id = "idshop_4"> 4 Product Archive Description</li> 327 <li id = "idshop_5"> 5 Print Notices</li> 328 <li id = "idshop_6"> 6 Result Count</li> 329 <li id = "idshop_7"> 7 Catalog Ordering</li> 330 <li id = "idshop_8"> 8 Pagination</li> 331 <li id = "idshop_9"> 9 Content Wrapper End</li> 332 </ul> 333 334 <ul id="sortable_shop2" class="connectedSortable"> 335 Trash 336 </ul> 337 338 339 <div class="defualt-push-button"> 340 <button type="button" id = "default_layers_shop">Default Layout</button> 341 <input id= 'serilization-layers-shop' type="text" name="serialization_stack_shop" value="<?php echo esc_html( $options['serialization_stack_shop'] ); ?>"/><br /> 342 </div> 343 </div> 344 345 <div id="shop-products"> 346 <h6 class="h6-class">Shop Products Layout</h6> 347 <ul id="sortable_shop1pr" class="connectedSortable"> 348 <li id = "idshoppr_1"> 1 Show Product Sale Flash</li> 349 <li id = "idshoppr_2"> 2 Product Thumbnail</li> 350 <li id = "idshoppr_3"> 3 Product Title</li> 351 <li id = "idshoppr_4"> 4 Product Price</li> 352 <li id = "idshoppr_5"> 5 Product Rating</li> 353 <li id = "idshoppr_6"> 6 Product Add to Cart Button</li> 354 </ul> 355 <ul id="sortable_shop2pr" class="connectedSortable"> 356 Trash 357 </ul> 358 359 360 <div class="defualt-push-button"> 361 <button type="button" id = "default_layers_shop_products">Default Layout</button> 362 <input id= 'serilization-layers-shop-products' type="text" name="serialization_stack_shop_products" value="<?php echo esc_html( $options['serialization_stack_shop_products'] );?>"/><br /> 363 </div> 364 </div> 365 <?php } // function Shop_Layout_Editor( $options ) 366 367 368 // -------------- update shop layers according admin settings -------------------------------------------------------- 369 370 add_action( 'wp_head', 'woolayedtil_arrange_woo_layers_according_sortable_shop',10 ); 371 function woolayedtil_arrange_woo_layers_according_sortable_shop(){ 372 373 $original_archtucture_shop = array( 374 array(0, 'woocommerce_output_content_wrapper', 10), 375 array(1, 'woocommerce_breadcrumb', 20), 376 377 array(2, 'woocommerce_taxonomy_archive_description', 10), 378 array(3, 'woocommerce_product_archive_description', 10), 379 380 array(4, 'wc_print_notices', 10), 381 array(5, 'woocommerce_result_count', 20), 382 array(6, 'woocommerce_catalog_ordering', 30), 383 384 385 array(7, 'woocommerce_pagination', 10), 386 387 array(8, 'woocommerce_output_content_wrapper_end', 10) 388 389 ); 390 391 // first take off all the layers one by one 392 393 for ($index_counter = 0; $index_counter < 9; $index_counter++){ 394 if ($index_counter < 2){ 395 remove_action('woocommerce_before_main_content', $original_archtucture_shop[$index_counter][1], $original_archtucture_shop[$index_counter][2] ); 396 } 397 else if (2 <= $index_counter && $index_counter <= 3 ){ 398 remove_action('woocommerce_archive_description', $original_archtucture_shop[$index_counter][1], $original_archtucture_shop[$index_counter][2] ); 399 } 400 else if (4 <= $index_counter && $index_counter <= 6 ){ 401 remove_action('woocommerce_before_shop_loop', $original_archtucture_shop[$index_counter][1], $original_archtucture_shop[$index_counter][2] ); 402 } 403 else if ($index_counter == 7 ){ 404 remove_action('woocommerce_after_shop_loop', $original_archtucture_shop[$index_counter][1], $original_archtucture_shop[$index_counter][2] ); 405 } 406 }// for ($index_counter = 0; $index_counter < 12; $index_counter++){ 407 408 // just for debugging 409 //exit(); 410 411 // build shop layers according to options from DB 412 413 global $options; 414 $serialize_data_before_processing_shop = $options['serialization_stack_shop']; 415 //$serialize_data_before_processing_shop = substr($serialize_data_before_processing_shop,5);// i.e 3&id[]=6&id[]=7&i 416 $serialize_data_before_processing_shop = substr($serialize_data_before_processing_shop,9);// i.e 3&idshio[]=6&idshop[]=7&i 417 //$index_counter = 1; // corresponds to "On Sale Indication" - woocommerce_show_product_sale_flash - 10 418 419 420 for ($index_counter = 0; $index_counter < 9; $index_counter++) 421 { 422 // extract each layer ID from the serialized options 423 $current_layer_id = null; 424 $index_of_next_prefix = strpos($serialize_data_before_processing_shop, '&'); 425 //if ($index_of_next_prefix == true) 426 if ($index_of_next_prefix > 0){ 427 $current_layer_id = substr($serialize_data_before_processing_shop, 0, $index_of_next_prefix); 428 } 429 else{ 430 if (is_numeric($serialize_data_before_processing_shop)) { 431 $current_layer_id = $serialize_data_before_processing_shop; 432 } 433 } 434 // reduce one because in array we count from 0 and not 1 435 $current_layer_id--; 436 437 // actual work 438 439 if ($index_counter < 2){ 440 if(is_numeric($current_layer_id)){ 441 add_action('woocommerce_before_main_content', $original_archtucture_shop[$current_layer_id][1], $original_archtucture_shop[$index_counter][2] ); 442 } 443 } 444 else if (2 <= $index_counter && $index_counter <= 3 ){ 445 if(is_numeric($current_layer_id)){ 446 add_action('woocommerce_archive_description', $original_archtucture_shop[$current_layer_id][1], $original_archtucture_shop[$index_counter][2] ); 447 } 448 } 449 else if (4 <= $index_counter && $index_counter <= 6 ){ 450 if(is_numeric($current_layer_id)){ 451 add_action('woocommerce_before_shop_loop', $original_archtucture_shop[$current_layer_id][1], $original_archtucture_shop[$index_counter][2] ); 452 } 453 } 454 else if ($index_counter == 7 ){ 455 if(is_numeric($current_layer_id)){ 456 add_action('woocommerce_after_shop_loop', $original_archtucture_shop[$current_layer_id][1], $original_archtucture_shop[$index_counter][2] ); 457 } 458 } 459 else if ($index_counter == 8 ){ 460 if(is_numeric($current_layer_id)){ 461 add_action('woocommerce_after_main_content', $original_archtucture_shop[$current_layer_id][1], $original_archtucture_shop[$index_counter][2] ); 462 } 463 } 464 465 // hook selected laye 466 //} // else 467 468 469 // prepare for next round 470 //$serialize_data_before_processing_shop = substr($serialize_data_before_processing_shop, $index_of_next_prefix + 6); 471 $serialize_data_before_processing_shop = substr($serialize_data_before_processing_shop, $index_of_next_prefix + 10); 472 //$index_counter++; 473 474 // debug only - enable one loop 475 476 //$serialize_data_before_processing_shop = ''; 477 } // for ($index_counter = 1; $index_counter < 10; $index_counter++) 478 479 } // function arrange_woocommerce_layers_according_sortable_shop(){ 480 481 //-------------- Shop Layer Products 482 483 add_action( 'wp_head', 'woolayedtil_arrange_woo_layers_according_sortable_shop_products',10 ); 484 function woolayedtil_arrange_woo_layers_according_sortable_shop_products(){ 485 486 $original_archtucture_shop_products = array( 487 array(0, 'woocommerce_show_product_loop_sale_flash', 10), 488 array(1, 'woocommerce_template_loop_product_thumbnail', 10), 489 490 array(2, 'woocommerce_template_loop_product_title', 10), 491 array(3, 'woocommerce_template_loop_price', 10), 492 493 array(4, 'woocommerce_template_loop_rating', 5), 494 array(5, 'woocommerce_template_loop_add_to_cart', 10), 495 ); 496 497 // first take off all the layers one by one - Shop Layer Products 498 499 for ($index_counter = 0; $index_counter < 6; $index_counter++){ 500 if ($index_counter < 2){ 501 remove_action('woocommerce_before_shop_loop_item_title', $original_archtucture_shop_products[$index_counter][1], $original_archtucture_shop_products[$index_counter][2] ); 502 } 503 else if ($index_counter == 2 ){ 504 remove_action('woocommerce_shop_loop_item_title', $original_archtucture_shop_products[$index_counter][1], $original_archtucture_shop_products[$index_counter][2] ); 505 } 506 else if (3 <= $index_counter && $index_counter <= 4 ){ 507 remove_action('woocommerce_after_shop_loop_item_title', $original_archtucture_shop_products[$index_counter][1], $original_archtucture_shop_products[$index_counter][2] ); 508 } 509 else if ($index_counter == 5 ){ 510 remove_action('woocommerce_after_shop_loop_item', $original_archtucture_shop_products[$index_counter][1], $original_archtucture_shop_products[$index_counter][2] ); 511 } 512 }// for ($index_counter = 0; $index_counter < 12; $index_counter++){ 513 514 // just for debugging 515 //exit(); 516 517 // build shop layers products according to options from DB 518 519 global $options; 520 $serialize_data_before_processing_shop_products = $options['serialization_stack_shop_products']; 521 //$serialize_data_before_processing_shop = substr($serialize_data_before_processing_shop,5);// i.e 3&id[]=6&id[]=7&i 522 $serialize_data_before_processing_shop_products = substr($serialize_data_before_processing_shop_products,11);// i.e 3&idshio[]=6&idshoppr[]=7&i 523 //$index_counter = 1; // corresponds to "On Sale Indication" - woocommerce_show_product_sale_flash - 10 524 525 526 for ($index_counter = 0; $index_counter < 6; $index_counter++) 527 { 528 // extract each layer ID from the serialized options 529 $current_layer_id = null; 530 $index_of_next_prefix = strpos($serialize_data_before_processing_shop_products, '&'); 531 //if ($index_of_next_prefix == true) 532 if ($index_of_next_prefix > 0){ 533 $current_layer_id = substr($serialize_data_before_processing_shop_products, 0, $index_of_next_prefix); 534 } 535 else{ 536 if (is_numeric($serialize_data_before_processing_shop_products)) { 537 $current_layer_id = $serialize_data_before_processing_shop_products; 538 } 539 } 540 // reduce one because in array we count from 0 and not 1 541 $current_layer_id--; 542 543 // actual work 544 545 if ($index_counter < 2){ 546 if(is_numeric($current_layer_id)){ 547 add_action('woocommerce_before_shop_loop_item_title', $original_archtucture_shop_products[$current_layer_id][1], $original_archtucture_shop_products[$index_counter][2] ); 548 } 549 } 550 else if ($index_counter == 2 ){ 551 if(is_numeric($current_layer_id)){ 552 add_action('woocommerce_shop_loop_item_title', $original_archtucture_shop_products[$current_layer_id][1], $original_archtucture_shop_products[$index_counter][2] ); 553 } 554 } 555 else if (3 <= $index_counter && $index_counter <= 4 ){ 556 if(is_numeric($current_layer_id)){ 557 add_action('woocommerce_after_shop_loop_item_title', $original_archtucture_shop_products[$current_layer_id][1], $original_archtucture_shop_products[$index_counter][2] ); 558 } 559 } 560 else if ($index_counter == 5 ){ 561 if(is_numeric($current_layer_id)){ 562 add_action('woocommerce_after_shop_loop_item', $original_archtucture_shop_products[$current_layer_id][1], $original_archtucture_shop_products[$index_counter][2] ); 563 } 564 } 565 566 // hook selected laye 567 //} // else 568 569 570 // prepare for next round 571 //$serialize_data_before_processing_shop = substr($serialize_data_before_processing_shop, $index_of_next_prefix + 6); 572 $serialize_data_before_processing_shop_products = substr($serialize_data_before_processing_shop_products, $index_of_next_prefix + 12); 573 //$index_counter++; 574 575 // debug only - enable one loop 576 577 //$serialize_data_before_processing_shop = ''; 578 } // for ($index_counter = 1; $index_counter < 10; $index_counter++) 579 580 } // function arrange_woocommerce_layers_according_sortable_shop_products(){ 581 582 /******************************************************************************************************* 583 * Product_layout_Editor_Meta_Box 584 ********************************************************************************************************/ 585 586 function woolayedtil_Product_layout_Editor_Meta_Box( $options ) 587 { ?> 588 <div id="product-layout"> 589 <h6 class="h6-class">Product Layout</h6> 590 <ul id="sortable1" class="connectedSortable"> 591 <li id = "id_1"> 1 On Sale Indication</li> 592 <li id = "id_2"> 2 Product Feature Image</li> 593 <li id = "id_3"> 3 Product Title</li> 594 <li id = "id_4"> 4 Product Rating</li> 595 <li id = "id_5"> 5 Product Price</li> 596 <li id = "id_6"> 6 Short Description(excerpt)</li> 597 <li id = "id_7"> 7 Add to Cart Button</li> 598 <li id = "id_8"> 8 Product Categories Meta Box</li> 599 <li id = "id_9"> 9 Social Sharing Button</li> 600 <li id = "id_10"> 10 Data Tabs and Their Content</li> 601 <li id = "id_11"> 11 Product Upsell Sisply</li> 602 <li id = "id_12">12 Related Products</li> 603 </ul> 604 605 <ul id="sortable2" class="connectedSortable"> 606 Trash 607 </ul> 608 </div> 609 610 <button type="button" id = "default_layers">Default Layout</button> 611 <div id="seialize-div"> 612 <input id="serialize-layers" type="text" name="serialization_stack" value="<?php echo esc_html( $options['serialization_stack'] ); ?>"/><br /> 613 </div> 614 615 <?php } // function Product_layout_Editor_Meta_Box( $options ) 616 617 618 add_action( 'wp_head', 'woolayedtil_arrange_woo_layers_according_sortable', 10 ); 619 function woolayedtil_arrange_woo_layers_according_sortable(){ 620 621 $original_archtucture = array( 622 array(0, 'woocommerce_show_product_sale_flash', 10), 623 array(1, 'woocommerce_show_product_images', 20), 624 625 array(2, 'woocommerce_template_single_title', 5), 626 array(3, 'woocommerce_template_single_rating', 10), 627 array(4, 'woocommerce_template_single_price', 10), 628 array(5, 'woocommerce_template_single_excerpt', 20), 629 array(6, 'woocommerce_template_single_add_to_cart', 30), 630 array(7, 'woocommerce_template_single_meta', 40), 631 array(8, 'woocommerce_template_single_sharing', 50), 632 633 array(9, 'woocommerce_output_product_data_tabs', 10), 634 array(10, 'woocommerce_upsell_display', 15), 635 array(11, 'woocommerce_output_related_products', 20) 636 ); 637 638 // first take off all the layers one by one 639 640 for ($index_counter = 0; $index_counter < 12; $index_counter++){ 641 if ($index_counter < 2){ 642 remove_action('woocommerce_before_single_product_summary', $original_archtucture[$index_counter][1], $original_archtucture[$index_counter][2] ); 643 } 644 else if (1 < $index_counter && $index_counter < 9 ){ 645 remove_action('woocommerce_single_product_summary', $original_archtucture[$index_counter][1], $original_archtucture[$index_counter][2] ); 646 } 647 else{ 648 remove_action('woocommerce_after_single_product_summary', $original_archtucture[$index_counter][1], $original_archtucture[$index_counter][2] ); 649 } 650 }// for ($index_counter = 0; $index_counter < 12; $index_counter++){ 651 652 653 global $options; 654 $serialize_data_before_processing = $options['serialization_stack']; 655 $serialize_data_before_processing = substr($serialize_data_before_processing,5);// i.e 3&id[]=6&id[]=7&i 656 //$index_counter = 1; // corresponds to "On Sale Indication" - woocommerce_show_product_sale_flash - 10 657 //while ($serialize_data_before_processing) 658 for ($index_counter = 0; $index_counter < 12; $index_counter++) 659 { 660 $current_layer_id = null; 661 $index_of_next_prefix = strpos($serialize_data_before_processing, '&'); 662 //if ($index_of_next_prefix == true) 663 if ($index_of_next_prefix > 0){ 664 $current_layer_id = substr($serialize_data_before_processing, 0, $index_of_next_prefix); 665 } 666 else{ 667 if (is_numeric($serialize_data_before_processing)) 668 $current_layer_id = $serialize_data_before_processing; 669 } 670 // reduce one because in array we count from 0 and not 1 671 $current_layer_id--; 672 673 // actual work 674 675 if ($index_counter < 2){ 676 if(is_numeric($current_layer_id)){ 677 add_action('woocommerce_before_single_product_summary', $original_archtucture[$current_layer_id][1], $original_archtucture[$index_counter][2] ); 678 } 679 } 680 else if (1 < $index_counter && $index_counter < 9 ){ 681 if(is_numeric($current_layer_id)){ 682 add_action('woocommerce_single_product_summary', $original_archtucture[$current_layer_id][1], $original_archtucture[$index_counter][2] ); 683 } 684 } 685 else{ 686 if(is_numeric($current_layer_id)){ 687 add_action('woocommerce_after_single_product_summary', $original_archtucture[$current_layer_id][1], $original_archtucture[$index_counter][2] ); 688 } 689 } 690 691 // hook selected laye 692 //} // else 693 694 695 // prepare for next round 696 $serialize_data_before_processing = substr($serialize_data_before_processing, $index_of_next_prefix + 6); 697 //$index_counter++; 698 699 // debug only - enable one loop 700 701 //$serialize_data_before_processing = ''; 702 } // for ($index_counter = 1; $index_counter < 10; $index_counter++) 703 704 } // function arrange_woocommerce_layers_according_sortable(){ 705 706 379 include dirname( __FILE__ ) . '/lib/simple_html_dom.php'; 380 include dirname( __FILE__ ) . '/shop_layout.php'; 381 include dirname( __FILE__ ) . '/shop_products_layout.php'; 382 include dirname( __FILE__ ) . '/product_layout.php'; 383 ?>
Note: See TracChangeset
for help on using the changeset viewer.