| @@ -1,411 +1,366 @@ | ||
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * BuilderFns class | |
| 4 | - * | |
| 5 | - * The builder. | |
| 6 | - * | |
| 7 | - * @package RadiusTheme\SB | |
| 8 | - * @since 1.0.0 | |
| 9 | - */ | |
| 10 | - | |
| 11 | -namespace RadiusTheme\SB\Helpers; | |
| 12 | - | |
| 13 | -// Do not allow directly accessing this file. | |
| 14 | -use RadiusTheme\SB\Models\TemplateSettings; | |
| 15 | - | |
| 16 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 17 | - exit( 'This script cannot be accessed directly.' ); | |
| 18 | -} | |
| 19 | - | |
| 20 | -/** | |
| 21 | - * BuilderFns class | |
| 22 | - */ | |
| 23 | -class BuilderFns { | |
| 24 | - /** | |
| 25 | - * Local Cache. | |
| 26 | - * | |
| 27 | - * @var array | |
| 28 | - */ | |
| 29 | - private static $cache = []; | |
| 30 | - | |
| 31 | - /** | |
| 32 | - * Template builder post type | |
| 33 | - * | |
| 34 | - * @var string | |
| 35 | - */ | |
| 36 | - public static $post_type_tb = 'rtsb_builder'; | |
| 37 | - /** | |
| 38 | - * Template builder | |
| 39 | - * | |
| 40 | - * @var string | |
| 41 | - */ | |
| 42 | - public static $template_meta = 'rtsb_tb_template'; | |
| 43 | - /** | |
| 44 | - * Template builder | |
| 45 | - * | |
| 46 | - * @var string | |
| 47 | - */ | |
| 48 | - public static $product_template_meta = 'rtsb_selected_product_template'; | |
| 49 | - /** | |
| 50 | - * Template builder | |
| 51 | - * | |
| 52 | - * @var string | |
| 53 | - */ | |
| 54 | - public static $view_template_for_products_meta = 'rtsb_template_for_selected_products'; | |
| 55 | - /** | |
| 56 | - * Template builder | |
| 57 | - * | |
| 58 | - * @var string | |
| 59 | - */ | |
| 60 | - public static $view_template_for_archive_meta = 'rtsb_template_for_selected_category'; | |
| 61 | - | |
| 62 | - /** | |
| 63 | - * Page builder id. | |
| 64 | - * | |
| 65 | - * @return int | |
| 66 | - */ | |
| 67 | - public static function builder_page_id_by_type( $type ) { | |
| 68 | - global $post; | |
| 69 | - | |
| 70 | - if ( ! array_key_exists( $type, self::builder_page_types() ) ) { | |
| 71 | - return 0; | |
| 72 | - } | |
| 73 | - | |
| 74 | - // Wpml Supported. | |
| 75 | - $options = self::option_name( $type ); | |
| 76 | - $post_id = TemplateSettings::instance()->get_option( $options ); | |
| 77 | - if ( empty( $post ) ) { | |
| 78 | - return $post_id; | |
| 79 | - } | |
| 80 | - | |
| 81 | - if ( empty( $post_id ) ) { | |
| 82 | - $options = self::option_name( $type, true ); | |
| 83 | - $post_id = TemplateSettings::instance()->get_option( $options ); | |
| 84 | - } | |
| 85 | - | |
| 86 | - $cache_key = 'rtsb_builder_page_id_by_type_' . $type; | |
| 87 | - if ( isset( self::$cache[ $cache_key ] ) ) { | |
| 88 | - return self::$cache[ $cache_key ]; | |
| 89 | - } | |
| 90 | - switch ( $type ) { | |
| 91 | - case 'product': | |
| 92 | - if ( 'product' === $post->post_type ) { | |
| 93 | - $builder_id = get_post_meta( get_the_ID(), self::$view_template_for_products_meta, true ); | |
| 94 | - $set_default = self::get_specific_product_as_default( $builder_id ); | |
| 95 | - | |
| 96 | - if ( 'publish' === $post->post_status ) { | |
| 97 | - $post_id = $builder_id && $set_default ? $builder_id : $post_id; | |
| 98 | - } | |
| 99 | - } | |
| 100 | - break; | |
| 101 | - case 'archive': | |
| 102 | - $queried_object = get_queried_object(); | |
| 103 | - | |
| 104 | - if ( ! empty( $queried_object->taxonomy ) && 'product_cat' === $queried_object->taxonomy ) { | |
| 105 | - $builder_id = get_term_meta( $queried_object->term_id, self::$view_template_for_archive_meta, true ); | |
| 106 | - $set_default = self::get_specific_category_as_default( $builder_id ); | |
| 107 | - | |
| 108 | - if ( 'publish' === $post->post_status ) { | |
| 109 | - $post_id = $builder_id && $set_default ? $builder_id : $post_id; | |
| 110 | - } | |
| 111 | - } | |
| 112 | - break; | |
| 113 | - | |
| 114 | - default: | |
| 115 | - } | |
| 116 | - if ( 'publish' === $post->post_status && self::builder_type( $post_id ) === $type ) { | |
| 117 | - self::$cache[ $cache_key ] = $post_id; | |
| 118 | - return $post_id; | |
| 119 | - } | |
| 120 | - | |
| 121 | - return $post_id; | |
| 122 | - } | |
| 123 | - | |
| 124 | - /** | |
| 125 | - * Page builder id. | |
| 126 | - * | |
| 127 | - * @return init | |
| 128 | - */ | |
| 129 | - public static function builder_page_id_by_page() { | |
| 130 | - $type = apply_filters( 'rtsb/builder/set/current/page/type', '' ); | |
| 131 | - if ( ! $type ) { | |
| 132 | - return; | |
| 133 | - } | |
| 134 | - | |
| 135 | - return self::builder_page_id_by_type( $type ); | |
| 136 | - } | |
| 137 | - | |
| 138 | - /** | |
| 139 | - * Page builder Page for. | |
| 140 | - * | |
| 141 | - * @return array | |
| 142 | - */ | |
| 143 | - public static function builder_page_types() { | |
| 144 | - $page_types = [ | |
| 145 | - 'shop' => esc_html__( 'Shop', 'shopbuilder' ), | |
| 146 | - 'archive' => esc_html__( 'Category Archive', 'shopbuilder' ), | |
| 147 | - 'product' => esc_html__( 'Product Page', 'shopbuilder' ), | |
| 148 | - 'cart' => esc_html__( 'Cart', 'shopbuilder' ), | |
| 149 | - 'checkout' => esc_html__( 'Checkout', 'shopbuilder' ), | |
| 150 | - ]; | |
| 151 | - | |
| 152 | - return apply_filters( 'rtsb/builder/register/page/types', $page_types ); | |
| 153 | - } | |
| 154 | - | |
| 155 | - /** | |
| 156 | - * Option name. | |
| 157 | - * | |
| 158 | - * @param string $type Builder type. | |
| 159 | - * | |
| 160 | - * @return string | |
| 161 | - */ | |
| 162 | - public static function option_name( $type, $default_lang = false ) { | |
| 163 | - | |
| 164 | - $type = str_replace( [ '-', ' ' ], '_', $type ); | |
| 165 | - $suffix = $type; | |
| 166 | - | |
| 167 | - if ( $default_lang ) { | |
| 168 | - return self::$template_meta . '_default_' . $suffix; | |
| 169 | - } | |
| 170 | - $current_lang = Fns::wpml_current_language(); | |
| 171 | - | |
| 172 | - if ( ! empty( $current_lang ) ) { | |
| 173 | - $suffix = $type . '_' . $current_lang; | |
| 174 | - } | |
| 175 | - | |
| 176 | - return self::$template_meta . '_default_' . $suffix; | |
| 177 | - } | |
| 178 | - | |
| 179 | - /** | |
| 180 | - * @param $post_id | |
| 181 | - * | |
| 182 | - * @return string|void | |
| 183 | - */ | |
| 184 | - public static function option_name_for_specific_product_set_default( $post_id ) { | |
| 185 | - if ( ! $post_id ) { | |
| 186 | - return; | |
| 187 | - } | |
| 188 | - | |
| 189 | - return 'rtsb_template_specific_product_set_default_' . $post_id; | |
| 190 | - } | |
| 191 | - | |
| 192 | - /** | |
| 193 | - * @param $post_id | |
| 194 | - * | |
| 195 | - * @return false|mixed|void|null | |
| 196 | - */ | |
| 197 | - public static function get_specific_product_as_default( $post_id ) { | |
| 198 | - if ( ! $post_id ) { | |
| 199 | - return; | |
| 200 | - } | |
| 201 | - $options = self::option_name_for_specific_product_set_default( $post_id ); | |
| 202 | - | |
| 203 | - return TemplateSettings::instance()->get_option( $options ); // get_option( $options ); | |
| 204 | - } | |
| 205 | - | |
| 206 | - /** | |
| 207 | - * @param $post_id | |
| 208 | - * | |
| 209 | - * @return string|void | |
| 210 | - */ | |
| 211 | - public static function option_name_for_specific_category_set_default( $post_id ) { | |
| 212 | - if ( ! $post_id ) { | |
| 213 | - return; | |
| 214 | - } | |
| 215 | - | |
| 216 | - return 'rtsb_template_specific_category_set_default_' . $post_id; | |
| 217 | - } | |
| 218 | - | |
| 219 | - /** | |
| 220 | - * @param $post_id | |
| 221 | - * | |
| 222 | - * @return false|mixed|void|null | |
| 223 | - */ | |
| 224 | - public static function get_specific_category_as_default( $post_id ) { | |
| 225 | - if ( ! $post_id ) { | |
| 226 | - return; | |
| 227 | - } | |
| 228 | - $options = self::option_name_for_specific_category_set_default( $post_id ); | |
| 229 | - | |
| 230 | - return TemplateSettings::instance()->get_option( $options ); // get_option( $options ); | |
| 231 | - } | |
| 232 | - | |
| 233 | - /** | |
| 234 | - * @param $template_id | |
| 235 | - * | |
| 236 | - * @return string | |
| 237 | - */ | |
| 238 | - public static function option_name_by_template_id( $template_id ) { | |
| 239 | - $_suff = null; | |
| 240 | - if ( $template_id ) { | |
| 241 | - $_suff = '_' . $template_id; | |
| 242 | - } | |
| 243 | - | |
| 244 | - return self::$view_template_for_products_meta . $_suff; | |
| 245 | - } | |
| 246 | - | |
| 247 | - /** | |
| 248 | - * @param $template_id | |
| 249 | - * | |
| 250 | - * @return string | |
| 251 | - */ | |
| 252 | - public static function archive_option_name_by_template_id( $template_id ) { | |
| 253 | - $_suff = null; | |
| 254 | - if ( $template_id ) { | |
| 255 | - $_suff = '_' . $template_id; | |
| 256 | - } | |
| 257 | - | |
| 258 | - return self::$view_template_for_archive_meta . $_suff; | |
| 259 | - } | |
| 260 | - | |
| 261 | - /** | |
| 262 | - * Template builder | |
| 263 | - * | |
| 264 | - * @var string | |
| 265 | - */ | |
| 266 | - public static function template_type_meta_key() { | |
| 267 | - return self::$template_meta . '_type'; | |
| 268 | - } | |
| 269 | - | |
| 270 | - /** | |
| 271 | - * Get builder type. | |
| 272 | - * | |
| 273 | - * @param [type] $post_id Post id. | |
| 274 | - * | |
| 275 | - * @return string | |
| 276 | - */ | |
| 277 | - public static function builder_type( $post_id ) { | |
| 278 | - | |
| 279 | - $post_id = Fns::wpml_object_id( $post_id, self::$post_type_tb, 'default' ); | |
| 280 | - | |
| 281 | - if ( ! $post_id ) { | |
| 282 | - return; | |
| 283 | - } | |
| 284 | - | |
| 285 | - $cache_key = 'rtsb_template_type_' . $post_id; | |
| 286 | - if ( isset( self::$cache[ $cache_key ] ) ) { | |
| 287 | - return self::$cache[ $cache_key ]; | |
| 288 | - } | |
| 289 | - | |
| 290 | - $type = get_post_meta( $post_id, self::template_type_meta_key(), true ); | |
| 291 | - | |
| 292 | - // Cache the results in a static variable for the next call. | |
| 293 | - self::$cache[ $cache_key ] = $type; | |
| 294 | - | |
| 295 | - return $type; | |
| 296 | - } | |
| 297 | - | |
| 298 | - /** | |
| 299 | - * Template builder | |
| 300 | - * | |
| 301 | - * @var boolean | |
| 302 | - */ | |
| 303 | - public static function is_builder_preview() { | |
| 304 | - return is_singular( self::$post_type_tb ); | |
| 305 | - } | |
| 306 | - | |
| 307 | - /** | |
| 308 | - * Template builder | |
| 309 | - * | |
| 310 | - * @var boolean | |
| 311 | - */ | |
| 312 | - public static function is_archive() { | |
| 313 | - return self::is_page_builder( 'archive', is_product_taxonomy() ); | |
| 314 | - } | |
| 315 | - | |
| 316 | - /** | |
| 317 | - * Template builder | |
| 318 | - * | |
| 319 | - * @var boolean | |
| 320 | - */ | |
| 321 | - public static function is_shop() { | |
| 322 | - return self::is_page_builder( 'shop', is_shop() ); | |
| 323 | - } | |
| 324 | - | |
| 325 | - /** | |
| 326 | - * Template builder | |
| 327 | - * | |
| 328 | - * @var boolean | |
| 329 | - */ | |
| 330 | - public static function is_cart() { | |
| 331 | - return self::is_page_builder( 'cart', is_cart() ); | |
| 332 | - } | |
| 333 | - | |
| 334 | - /** | |
| 335 | - * Template builder | |
| 336 | - * | |
| 337 | - * @var boolean | |
| 338 | - */ | |
| 339 | - public static function is_checkout() { | |
| 340 | - return self::is_page_builder( 'checkout', is_checkout() && ! is_wc_endpoint_url() && ! is_order_received_page() ); | |
| 341 | - } | |
| 342 | - | |
| 343 | - /** | |
| 344 | - * Single Page builder Detection | |
| 345 | - * | |
| 346 | - * @return boolean | |
| 347 | - */ | |
| 348 | - public static function is_product() { | |
| 349 | - return self::is_page_builder( 'product', is_product() ); | |
| 350 | - } | |
| 351 | - | |
| 352 | - /** | |
| 353 | - * @param $is_quick_view | |
| 354 | - * | |
| 355 | - * @return bool | |
| 356 | - */ | |
| 357 | - public static function is_quick_views_page( $is_quick_view = false ) { | |
| 358 | - return rtsb()->has_pro() && self::is_page_builder( 'quick-view', $is_quick_view ); | |
| 359 | - } | |
| 360 | - | |
| 361 | - /** | |
| 362 | - * Builder page detector. | |
| 363 | - * | |
| 364 | - * @param string $type builder Page type. | |
| 365 | - * @param boolean $is_page page status. | |
| 366 | - * | |
| 367 | - * @return boolean | |
| 368 | - */ | |
| 369 | - public static function is_page_builder( $type, $is_page, $is_require_auth = false ) { | |
| 370 | - // if ( 'myaccount-dashboard' === $type ) { | |
| 371 | - // $current_url = esc_url_raw( home_url( add_query_arg( null, null ) ) ); | |
| 372 | - // | |
| 373 | - // if ( wc_get_account_endpoint_url( 'dashboard' ) !== $current_url ) { | |
| 374 | - // return false; | |
| 375 | - // } | |
| 376 | - // } | |
| 377 | - | |
| 378 | - if ( self::builder_type( get_the_ID() ) === $type ) { | |
| 379 | - return true; | |
| 380 | - } | |
| 381 | - | |
| 382 | - if ( $is_require_auth && ! is_user_logged_in() ) { | |
| 383 | - $type = 'myaccount-auth'; | |
| 384 | - } | |
| 385 | - | |
| 386 | - $builder_id = self::builder_page_id_by_type( $type ); | |
| 387 | - if ( ! $builder_id ) { | |
| 388 | - return false; | |
| 389 | - } | |
| 390 | - | |
| 391 | - $builder_type = self::builder_type( $builder_id ); | |
| 392 | - if ( $type === $builder_type && $is_page ) { | |
| 393 | - return true; | |
| 394 | - } | |
| 395 | - | |
| 396 | - return false; | |
| 397 | - } | |
| 398 | - | |
| 399 | - /** | |
| 400 | - * Get builder content function | |
| 401 | - * | |
| 402 | - * @param [type] $template_id builder Template id. | |
| 403 | - * @param boolean $with_css with css. | |
| 404 | - * | |
| 405 | - * @return mixed | |
| 406 | - */ | |
| 407 | - public static function get_builder_content( $template_id, $with_css = false ) { | |
| 408 | - // Don't Use cache: tickets ID -> 75376. | |
| 409 | - return \Elementor\Plugin::instance()->frontend->get_builder_content_for_display( $template_id, $with_css ); | |
| 410 | - } | |
| 411 | -} | |
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * BuilderFns class | |
| 4 | + * | |
| 5 | + * The builder. | |
| 6 | + * | |
| 7 | + * @package RadiusTheme\SB | |
| 8 | + * @since 1.0.0 | |
| 9 | + */ | |
| 10 | + | |
| 11 | +namespace RadiusTheme\SB\Helpers; | |
| 12 | + | |
| 13 | +// Do not allow directly accessing this file. | |
| 14 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 15 | + exit( 'This script cannot be accessed directly.' ); | |
| 16 | +} | |
| 17 | + | |
| 18 | +/** | |
| 19 | + * BuilderFns class | |
| 20 | + */ | |
| 21 | +class BuilderFns { | |
| 22 | + | |
| 23 | + /** | |
| 24 | + * Template builder post type | |
| 25 | + * | |
| 26 | + * @var string | |
| 27 | + */ | |
| 28 | + public static $post_type_tb = 'rtsb_builder'; | |
| 29 | + /** | |
| 30 | + * Template builder | |
| 31 | + * | |
| 32 | + * @var string | |
| 33 | + */ | |
| 34 | + public static $template_meta = 'rtsb_tb_template'; | |
| 35 | + /** | |
| 36 | + * Template builder | |
| 37 | + * | |
| 38 | + * @var string | |
| 39 | + */ | |
| 40 | + public static $product_template_meta = 'rtsb_selected_product_template'; | |
| 41 | + | |
| 42 | + /** | |
| 43 | + * Page builder id. | |
| 44 | + * | |
| 45 | + * @return init | |
| 46 | + */ | |
| 47 | + public static function builder_page_id_by_type( $type ) { | |
| 48 | + if ( array_key_exists( $type, self::builder_page_types() ) ) { | |
| 49 | + $post_id = get_option( self::option_name( $type ) ); | |
| 50 | + if ( 'publish' === get_post_status( $post_id ) && self::builder_type( $post_id ) === $type ) { | |
| 51 | + return $post_id; | |
| 52 | + } | |
| 53 | + } | |
| 54 | + return 0; | |
| 55 | + } | |
| 56 | + | |
| 57 | + /** | |
| 58 | + * Page builder id. | |
| 59 | + * | |
| 60 | + * @return init | |
| 61 | + */ | |
| 62 | + public static function builder_page_id_by_page() { | |
| 63 | + $type = apply_filters( 'rtsb/builder/set/current/page/type', '' ); | |
| 64 | + return self::builder_page_id_by_type( $type ); | |
| 65 | + } | |
| 66 | + /** | |
| 67 | + * Page builder Page for. | |
| 68 | + * | |
| 69 | + * @return array | |
| 70 | + */ | |
| 71 | + public static function builder_page_types() { | |
| 72 | + $page_types = [ | |
| 73 | + 'shop' => esc_html__( 'Shop', 'shopbuilder' ), | |
| 74 | + 'archive' => esc_html__( 'Archive', 'shopbuilder' ), | |
| 75 | + 'product' => esc_html__( 'Product Page', 'shopbuilder' ), | |
| 76 | + 'cart' => esc_html__( 'Cart', 'shopbuilder' ), | |
| 77 | + 'checkout' => esc_html__( 'Checkout', 'shopbuilder' ), | |
| 78 | + ]; | |
| 79 | + return apply_filters( 'rtsb/builder/page/types', $page_types ); | |
| 80 | + } | |
| 81 | + | |
| 82 | + /** | |
| 83 | + * Option name. | |
| 84 | + * | |
| 85 | + * @param string $type Builder type. | |
| 86 | + * @return string | |
| 87 | + */ | |
| 88 | + public static function option_name( $type ) { | |
| 89 | + $type = str_replace( [ '-', ' ' ], '_', $type ); | |
| 90 | + return self::$template_meta . '_default_' . $type; | |
| 91 | + } | |
| 92 | + /** | |
| 93 | + * Option name. | |
| 94 | + * | |
| 95 | + * @param string $type Builder type. | |
| 96 | + * @return string | |
| 97 | + */ | |
| 98 | + /* | |
| 99 | + public static function option_name_by_product_id( $type, $product_id ) { | |
| 100 | + return self::option_name($type) . '_' . $product_id ; | |
| 101 | + } | |
| 102 | + */ | |
| 103 | + /** | |
| 104 | + * Template builder | |
| 105 | + * | |
| 106 | + * @var string | |
| 107 | + */ | |
| 108 | + public static function template_type_meta_key() { | |
| 109 | + return self::$template_meta . '_type'; | |
| 110 | + } | |
| 111 | + /** | |
| 112 | + * Get builder type. | |
| 113 | + * | |
| 114 | + * @param [type] $post_id Post id. | |
| 115 | + * @return string | |
| 116 | + */ | |
| 117 | + public static function builder_type( $post_id ) { | |
| 118 | + return get_post_meta( $post_id, self::template_type_meta_key(), true ); | |
| 119 | + } | |
| 120 | + /** | |
| 121 | + * Template builder | |
| 122 | + * | |
| 123 | + * @var boolean | |
| 124 | + */ | |
| 125 | + public static function is_builder_preview() { | |
| 126 | + return is_singular( self::$post_type_tb ); | |
| 127 | + } | |
| 128 | + /** | |
| 129 | + * Template builder | |
| 130 | + * | |
| 131 | + * @var boolean | |
| 132 | + */ | |
| 133 | + public static function is_archive() { | |
| 134 | + return self::is_page_builder( 'archive', is_product_taxonomy() ); | |
| 135 | + } | |
| 136 | + /** | |
| 137 | + * Template builder | |
| 138 | + * | |
| 139 | + * @var boolean | |
| 140 | + */ | |
| 141 | + public static function is_shop() { | |
| 142 | + return self::is_page_builder( 'shop', is_shop() ); | |
| 143 | + } | |
| 144 | + /** | |
| 145 | + * Template builder | |
| 146 | + * | |
| 147 | + * @var boolean | |
| 148 | + */ | |
| 149 | + public static function is_cart() { | |
| 150 | + return self::is_page_builder( 'cart', is_cart() ); | |
| 151 | + } | |
| 152 | + /** | |
| 153 | + * Template builder | |
| 154 | + * | |
| 155 | + * @var boolean | |
| 156 | + */ | |
| 157 | + public static function is_checkout() { | |
| 158 | + return self::is_page_builder( 'checkout', is_checkout() && ! is_wc_endpoint_url() && ! is_order_received_page() ); | |
| 159 | + } | |
| 160 | + /** | |
| 161 | + * Single Page builder Detection | |
| 162 | + * | |
| 163 | + * @return boolean | |
| 164 | + */ | |
| 165 | + public static function is_product() { | |
| 166 | + return self::is_page_builder( 'product', is_product() ); | |
| 167 | + } | |
| 168 | + /** | |
| 169 | + * Builder page detector. | |
| 170 | + * | |
| 171 | + * @param string $type builder Page type. | |
| 172 | + * @param boolean $is_page page status. | |
| 173 | + * @return boolean | |
| 174 | + */ | |
| 175 | + public static function is_page_builder( $type, $is_page ) { | |
| 176 | + $builder_id = self::builder_page_id_by_type( $type ); | |
| 177 | + $builder_type = self::builder_type( $builder_id ); | |
| 178 | + $type_status = $type === $builder_type; // Ticket issue. | |
| 179 | + if ( self::builder_type( get_the_ID() ) === $type || ( $type_status && $is_page ) ) { | |
| 180 | + return true; | |
| 181 | + } | |
| 182 | + return false; | |
| 183 | + } | |
| 184 | + | |
| 185 | + /** | |
| 186 | + * Get builder content function | |
| 187 | + * | |
| 188 | + * @param [type] $template_id builder Template id. | |
| 189 | + * @param boolean $with_css with css. | |
| 190 | + * @return mixed | |
| 191 | + */ | |
| 192 | + public static function get_builder_content( $template_id, $with_css = false ) { | |
| 193 | + return \Elementor\Plugin::instance()->frontend->get_builder_content_for_display( $template_id, $with_css ); | |
| 194 | + } | |
| 195 | + | |
| 196 | + /** | |
| 197 | + * Page builder Page for. | |
| 198 | + * | |
| 199 | + * @return array | |
| 200 | + */ | |
| 201 | + public static function default_layout() { | |
| 202 | + $demo_root_url = 'https://shopbuilderwp.com'; | |
| 203 | + $page_layout = [ | |
| 204 | + 'default' => [ | |
| 205 | + [ | |
| 206 | + 'text_label' => __( 'Blank', 'shopbuilder' ), | |
| 207 | + 'image' => rtsb()->get_assets_uri( 'images/layout-preview/placeholder.png' ), | |
| 208 | + ], | |
| 209 | + ], | |
| 210 | + 'product' => [ | |
| 211 | + [ | |
| 212 | + 'text_label' => __( 'Product Layout 1', 'shopbuilder' ), | |
| 213 | + 'image' => rtsb()->get_assets_uri( 'images/layout-preview/product-single-demo-1.jpg' ), | |
| 214 | + 'live_preview' => $demo_root_url . '/rtsb-template/product-single-demo-1/', | |
| 215 | + 'import_file' => '/sample-layout/products/product-single-demo-1.json', | |
| 216 | + ], | |
| 217 | + [ | |
| 218 | + 'text_label' => __( 'Product Layout 2', 'shopbuilder' ), | |
| 219 | + 'image' => rtsb()->get_assets_uri( 'images/layout-preview/product-single-demo-2.jpg' ), | |
| 220 | + 'live_preview' => $demo_root_url . '/rtsb-template/product-single-demo-2', | |
| 221 | + 'import_file' => '/sample-layout/products/product-single-demo-2.json', | |
| 222 | + ], | |
| 223 | + [ | |
| 224 | + 'text_label' => __( 'Product Layout 3', 'shopbuilder' ), | |
| 225 | + 'image' => rtsb()->get_assets_uri( 'images/layout-preview/product-single-demo-3.jpg' ), | |
| 226 | + 'live_preview' => $demo_root_url . '/rtsb-template/product-single-demo-3/', | |
| 227 | + 'import_file' => '/sample-layout/products/product-single-demo-3.json', | |
| 228 | + ], | |
| 229 | + [ | |
| 230 | + 'text_label' => __( 'Product Layout 4', 'shopbuilder' ), | |
| 231 | + 'image' => rtsb()->get_assets_uri( 'images/layout-preview/product-single-demo-4.jpg' ), | |
| 232 | + 'live_preview' => $demo_root_url . '/rtsb-template/product-single-demo-4/', | |
| 233 | + 'import_file' => '/sample-layout/products/product-single-demo-4.json', | |
| 234 | + ], | |
| 235 | + [ | |
| 236 | + 'text_label' => __( 'Product Layout 5', 'shopbuilder' ), | |
| 237 | + 'image' => rtsb()->get_assets_uri( 'images/layout-preview/product-single-demo-5.jpg' ), | |
| 238 | + 'live_preview' => $demo_root_url . '/rtsb-template/product-single-demo-5/', | |
| 239 | + 'import_file' => '/sample-layout/products/product-single-demo-5.json', | |
| 240 | + ], | |
| 241 | + | |
| 242 | + ], | |
| 243 | + 'shop' => [ | |
| 244 | + [ | |
| 245 | + 'text_label' => __( 'Shop – Theme Default', 'shopbuilder' ), | |
| 246 | + 'image' => rtsb()->get_assets_uri( 'images/layout-preview/shop-theme-default.jpg' ), | |
| 247 | + 'live_preview' => $demo_root_url . '/shop/', | |
| 248 | + 'import_file' => '/sample-layout/shop/shop-theme-default.json', | |
| 249 | + ], | |
| 250 | + [ | |
| 251 | + 'text_label' => __( 'Shop – Left Sidebar', 'shopbuilder' ), | |
| 252 | + 'image' => rtsb()->get_assets_uri( 'images/layout-preview/shop-left-sidebar.jpg' ), | |
| 253 | + 'live_preview' => $demo_root_url . '/rtsb-template/shop-left-sidebar-shop-builder-custom/', | |
| 254 | + 'import_file' => '/sample-layout/shop/shop-left-sidebar.json', | |
| 255 | + ], | |
| 256 | + [ | |
| 257 | + 'text_label' => __( 'Shop - Custom Layout 1', 'shopbuilder' ), | |
| 258 | + 'image' => rtsb()->get_assets_uri( 'images/layout-preview/shop-custom-layout-1.jpg' ), | |
| 259 | + 'live_preview' => $demo_root_url . '/rtsb-template/shop-builder-custom-layout-1/', | |
| 260 | + 'import_file' => '/sample-layout/shop/shop-custom-layout-1.json', | |
| 261 | + ], | |
| 262 | + [ | |
| 263 | + 'text_label' => __( 'Shop - Custom Layout 2', 'shopbuilder' ), | |
| 264 | + 'image' => rtsb()->get_assets_uri( 'images/layout-preview/shop-custom-layout-2.jpg' ), | |
| 265 | + 'live_preview' => $demo_root_url . '/rtsb-template/shop-builder-custom-layout-2/', | |
| 266 | + 'import_file' => '/sample-layout/shop/shop–builder-custom-layout-2.json', | |
| 267 | + ], | |
| 268 | + [ | |
| 269 | + 'text_label' => __( 'Shop - List View 1', 'shopbuilder' ), | |
| 270 | + 'image' => rtsb()->get_assets_uri( 'images/layout-preview/shop-custom-layout-list-view-1.jpg' ), | |
| 271 | + 'live_preview' => $demo_root_url . '/rtsb-template/shop-builder-custom-layout-list-view-1/', | |
| 272 | + 'import_file' => '/sample-layout/shop/shop-custom-layout-list-view-1.json', | |
| 273 | + ], | |
| 274 | + [ | |
| 275 | + 'text_label' => __( 'Shop - List View 2', 'shopbuilder' ), | |
| 276 | + 'image' => rtsb()->get_assets_uri( 'images/layout-preview/shop-custom-layout-list-view-2.jpg' ), | |
| 277 | + 'live_preview' => $demo_root_url . '/rtsb-template/shop-builder-custom-layout-list-view-2/', | |
| 278 | + 'import_file' => '/sample-layout/shop/shop-custom-layout-list-view-2.json', | |
| 279 | + ], | |
| 280 | + ], | |
| 281 | + 'archive' => [ | |
| 282 | + [ | |
| 283 | + 'text_label' => __( 'Archive – Theme Default', 'shopbuilder' ), | |
| 284 | + 'image' => rtsb()->get_assets_uri( 'images/layout-preview/shop-theme-default.jpg' ), | |
| 285 | + 'live_preview' => $demo_root_url . '/shop/', | |
| 286 | + 'import_file' => '/sample-layout/shop/shop-theme-default.json', | |
| 287 | + ], | |
| 288 | + [ | |
| 289 | + 'text_label' => __( 'Archive – Left Sidebar', 'shopbuilder' ), | |
| 290 | + 'image' => rtsb()->get_assets_uri( 'images/layout-preview/shop-left-sidebar.jpg' ), | |
| 291 | + 'live_preview' => $demo_root_url . '/rtsb-template/shop-left-sidebar-shop-builder-custom/', | |
| 292 | + 'import_file' => '/sample-layout/shop/shop-left-sidebar.json', | |
| 293 | + ], | |
| 294 | + [ | |
| 295 | + 'text_label' => __( 'Archive - Custom Layout 1', 'shopbuilder' ), | |
| 296 | + 'image' => rtsb()->get_assets_uri( 'images/layout-preview/shop-custom-layout-1.jpg' ), | |
| 297 | + 'live_preview' => $demo_root_url . '/rtsb-template/shop-builder-custom-layout-1/', | |
| 298 | + 'import_file' => '/sample-layout/shop/shop-custom-layout-1.json', | |
| 299 | + ], | |
| 300 | + [ | |
| 301 | + 'text_label' => __( 'Archive - Custom Layout 2', 'shopbuilder' ), | |
| 302 | + 'image' => rtsb()->get_assets_uri( 'images/layout-preview/shop-custom-layout-2.jpg' ), | |
| 303 | + 'live_preview' => $demo_root_url . '/rtsb-template/shop-builder-custom-layout-2/', | |
| 304 | + 'import_file' => '/sample-layout/shop/shop–builder-custom-layout-2.json', | |
| 305 | + ], | |
| 306 | + [ | |
| 307 | + 'text_label' => __( 'Archive - List View 1', 'shopbuilder' ), | |
| 308 | + 'image' => rtsb()->get_assets_uri( 'images/layout-preview/shop-custom-layout-list-view-1.jpg' ), | |
| 309 | + 'live_preview' => $demo_root_url . '/rtsb-template/shop-builder-custom-layout-list-view-1/', | |
| 310 | + 'import_file' => '/sample-layout/shop/shop-custom-layout-list-view–1.json', | |
| 311 | + ], | |
| 312 | + [ | |
| 313 | + 'text_label' => __( 'Archive - List View 2', 'shopbuilder' ), | |
| 314 | + 'image' => rtsb()->get_assets_uri( 'images/layout-preview/shop-custom-layout-list-view-2.jpg' ), | |
| 315 | + 'live_preview' => $demo_root_url . '/rtsb-template/shop-builder-custom-layout-list-view-2/', | |
| 316 | + 'import_file' => '/sample-layout/shop/shop-custom-layout-list-view-2.json', | |
| 317 | + ], | |
| 318 | + | |
| 319 | + ], | |
| 320 | + 'cart' => [ | |
| 321 | + [ | |
| 322 | + 'text_label' => __( 'Cart - View 1', 'shopbuilder' ), | |
| 323 | + 'image' => rtsb()->get_assets_uri( 'images/layout-preview/cart-view-1.jpg' ), | |
| 324 | + 'live_preview' => $demo_root_url . '/rtsb-template/cart-page-demo-1/', | |
| 325 | + 'import_file' => '/sample-layout/cart/cart-view-1.json', | |
| 326 | + ], | |
| 327 | + [ | |
| 328 | + 'text_label' => __( 'Cart - View 2', 'shopbuilder' ), | |
| 329 | + 'image' => rtsb()->get_assets_uri( 'images/layout-preview/cart-view-2.jpg' ), | |
| 330 | + 'live_preview' => $demo_root_url . '/rtsb-template/cart-page-demo-2/', | |
| 331 | + 'import_file' => '/sample-layout/cart/cart-view-2.json', | |
| 332 | + ], | |
| 333 | + ], | |
| 334 | + 'checkout' => [ | |
| 335 | + [ | |
| 336 | + 'text_label' => __( 'Checkout - View 1', 'shopbuilder' ), | |
| 337 | + 'image' => rtsb()->get_assets_uri( 'images/layout-preview/checkout-demo-1.jpg' ), | |
| 338 | + 'live_preview' => $demo_root_url . '/rtsb-template/checkout-page-layout-1/', | |
| 339 | + 'import_file' => '/sample-layout/checkout/checkout-view-1.json', | |
| 340 | + ], | |
| 341 | + [ | |
| 342 | + 'text_label' => __( 'Checkout - View 2', 'shopbuilder' ), | |
| 343 | + 'image' => rtsb()->get_assets_uri( 'images/layout-preview/checkout-demo-2.jpg' ), | |
| 344 | + 'live_preview' => $demo_root_url . '/rtsb-template/checkout-page-demo-2/', | |
| 345 | + 'import_file' => '/sample-layout/checkout/checkout-view-2.json', | |
| 346 | + ], | |
| 347 | + [ | |
| 348 | + 'text_label' => __( 'Checkout - View 3', 'shopbuilder' ), | |
| 349 | + 'image' => rtsb()->get_assets_uri( 'images/layout-preview/checkout-demo-3.jpg' ), | |
| 350 | + 'live_preview' => $demo_root_url . '/rtsb-template/checkout-page-demo-3/', | |
| 351 | + 'import_file' => '/sample-layout/checkout/checkout-view-3.json', | |
| 352 | + ], | |
| 353 | + [ | |
| 354 | + 'text_label' => __( 'Checkout - View 4', 'shopbuilder' ), | |
| 355 | + 'image' => rtsb()->get_assets_uri( 'images/layout-preview/checkout-demo-4.jpg' ), | |
| 356 | + 'live_preview' => $demo_root_url . '/rtsb-template/checkout-page-demo-4/', | |
| 357 | + 'import_file' => '/sample-layout/checkout/checkout-view-4.json', | |
| 358 | + ], | |
| 359 | + | |
| 360 | + ], | |
| 361 | + ]; | |
| 362 | + $page_layout = apply_filters( 'rtsb/page/default/layout', $page_layout ); | |
| 363 | + return $page_layout; | |
| 364 | + } | |
| 365 | + | |
| 366 | +} | |