| @@ -1,94 +1,98 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -class EasyOptInsLayout { | |
| 4 | - public $layout_number; | |
| 5 | - public $layout_type; | |
| 6 | - public $layout_class; | |
| 7 | - public $layout_id; | |
| 8 | - | |
| 9 | - private $plugin_dir; | |
| 10 | - private $plugin_url; | |
| 11 | - | |
| 12 | - public static function uses_new_css() { | |
| 13 | - return (bool) paf( 'eoi_powerup_new_css' ); | |
| 14 | - } | |
| 15 | - | |
| 16 | - public function __construct( $layout_id ) { | |
| 17 | - $this->plugin_dir = FCA_EOI_PLUGIN_DIR; | |
| 18 | - $this->plugin_url = FCA_EOI_PLUGIN_URL . '/'; | |
| 19 | - | |
| 20 | - list( $layout_type, $layout_number ) = explode( '_', $layout_id ); | |
| 21 | - | |
| 22 | - $this->layout_number = (int) $layout_number; | |
| 23 | - $this->layout_type = $layout_type == 'layout' ? 'widget' : $layout_type; | |
| 24 | - $this->layout_class = self::generate_layout_class( $this->layout_type ); | |
| 25 | - $this->layout_id = $layout_id; | |
| 26 | - } | |
| 27 | - | |
| 28 | - public function new_scss_compiler() { | |
| 29 | - $scss = new scssc(); | |
| 30 | - $scss->setFormatter( 'scss_formatter_compressed' ); | |
| 31 | - $scss->addImportPath( $this->plugin_dir ); | |
| 32 | - | |
| 33 | - return $scss; | |
| 34 | - } | |
| 35 | - | |
| 36 | - public function path_to_html_wrapper() { | |
| 37 | - return $this->plugin_dir . $this->common_path() . $this->layout_type . '.html'; | |
| 38 | - } | |
| 39 | - | |
| 40 | - public function path_to_resource( $resource_name, $resource_type ) { | |
| 41 | - return $this->plugin_dir . $this->subpath_to_resource( $resource_name, $resource_type ); | |
| 42 | - } | |
| 43 | - | |
| 44 | - public function url_to_resource( $resource_name, $resource_type ) { | |
| 45 | - return $this->plugin_url . $this->subpath_to_resource( $resource_name, $resource_type ); | |
| 46 | - } | |
| 47 | - | |
| 48 | - private static function generate_layout_class( $layout_type ) { | |
| 49 | - if ( $layout_type == 'lightbox' ) { | |
| 50 | - return 'fca_eoi_layout_popup'; | |
| 51 | - } elseif ( $layout_type == 'postbox' ) { | |
| 52 | - return 'fca_eoi_layout_postbox'; | |
| 53 | - } elseif ( $layout_type == 'widget' ) { | |
| 54 | - return 'fca_eoi_layout_widget'; | |
| 55 | - } | |
| 56 | - return ''; | |
| 57 | - } | |
| 58 | - | |
| 59 | - private function subpath_to_resource( $resource_name, $resource_type ) { | |
| 60 | - if ( self::uses_new_css() ) { | |
| 61 | - if ( $resource_name == 'layout' && $resource_type == 'html' ) { | |
| 62 | - $new_path = | |
| 63 | - $this->common_path() . | |
| 64 | - 'layout_' . $this->layout_number . '/' . | |
| 65 | - $resource_name . '.' . $resource_type; | |
| 66 | - | |
| 67 | - if ( file_exists( $this->plugin_dir . $new_path ) ) { | |
| 68 | - return $new_path; | |
| 69 | - } | |
| 70 | - } | |
| 71 | - | |
| 72 | - $new_path = $this->subpath() . $resource_name . '-new.' . $resource_type; | |
| 73 | - if ( file_exists( $this->plugin_dir . $new_path ) ) { | |
| 74 | - return $new_path; | |
| 75 | - } | |
| 76 | - } | |
| 77 | - | |
| 78 | - $path = $this->subpath(); | |
| 79 | - | |
| 80 | - if ( $resource_type == 'scss' ) { | |
| 81 | - $resource_type = 'css'; | |
| 82 | - } | |
| 83 | - | |
| 84 | - return $path . $resource_name . '.' . $resource_type; | |
| 85 | - } | |
| 86 | - | |
| 87 | - private function subpath() { | |
| 88 | - return 'layouts/' . $this->layout_type . '/' . $this->layout_id . '/'; | |
| 89 | - } | |
| 90 | - | |
| 91 | - private function common_path() { | |
| 92 | - return 'layouts/common/'; | |
| 93 | - } | |
| 94 | -} | |
| 1 | +<?php | |
| 2 | + | |
| 3 | +class EasyOptInsLayout { | |
| 4 | + public $layout_number; | |
| 5 | + public $layout_type; | |
| 6 | + public $layout_class; | |
| 7 | + public $layout_id; | |
| 8 | + | |
| 9 | + private $plugin_dir; | |
| 10 | + private $plugin_url; | |
| 11 | + | |
| 12 | + public static function uses_new_css() { | |
| 13 | + return true; | |
| 14 | + } | |
| 15 | + | |
| 16 | + public function __construct( $layout_id ) { | |
| 17 | + $this->plugin_dir = FCA_EOI_PLUGIN_DIR; | |
| 18 | + $this->plugin_url = FCA_EOI_PLUGIN_URL . '/'; | |
| 19 | + | |
| 20 | + list( $layout_type, $layout_number ) = explode( '_', $layout_id ); | |
| 21 | + | |
| 22 | + $this->layout_number = (int) $layout_number; | |
| 23 | + $this->layout_type = $layout_type == 'layout' ? 'widget' : $layout_type; | |
| 24 | + $this->layout_class = self::generate_layout_class( $this->layout_type ); | |
| 25 | + $this->layout_id = $layout_id; | |
| 26 | + } | |
| 27 | + | |
| 28 | + public function new_scss_compiler() { | |
| 29 | + $scss = new scssc(); | |
| 30 | + $scss->setFormatter( 'scss_formatter_compressed' ); | |
| 31 | + $scss->addImportPath( $this->plugin_dir ); | |
| 32 | + | |
| 33 | + return $scss; | |
| 34 | + } | |
| 35 | + | |
| 36 | + public function path_to_html_wrapper() { | |
| 37 | + return $this->plugin_dir . $this->common_path() . $this->layout_type . '.html'; | |
| 38 | + } | |
| 39 | + | |
| 40 | + public function path_to_resource( $resource_name, $resource_type ) { | |
| 41 | + return $this->plugin_dir . $this->subpath_to_resource( $resource_name, $resource_type ); | |
| 42 | + } | |
| 43 | + | |
| 44 | + public function url_to_resource( $resource_name, $resource_type ) { | |
| 45 | + return $this->plugin_url . $this->subpath_to_resource( $resource_name, $resource_type ); | |
| 46 | + } | |
| 47 | + | |
| 48 | + private static function generate_layout_class( $layout_type ) { | |
| 49 | + if ( $layout_type == 'lightbox' ) { | |
| 50 | + return 'fca_eoi_layout_popup'; | |
| 51 | + } elseif ( $layout_type == 'postbox' ) { | |
| 52 | + return 'fca_eoi_layout_postbox'; | |
| 53 | + } elseif ( $layout_type == 'widget' ) { | |
| 54 | + return 'fca_eoi_layout_widget'; | |
| 55 | + } elseif ( $layout_type == 'banner' ) { | |
| 56 | + return 'fca_eoi_layout_banner'; | |
| 57 | + } elseif ( $layout_type == 'overlay' ) { | |
| 58 | + return 'fca_eoi_layout_overlay'; | |
| 59 | + } | |
| 60 | + return ''; | |
| 61 | + } | |
| 62 | + | |
| 63 | + private function subpath_to_resource( $resource_name, $resource_type ) { | |
| 64 | + if ( self::uses_new_css() ) { | |
| 65 | + if ( $resource_name == 'layout' && $resource_type == 'html' ) { | |
| 66 | + $new_path = | |
| 67 | + $this->common_path() . | |
| 68 | + 'layout_' . $this->layout_number . '/' . | |
| 69 | + $resource_name . '.' . $resource_type; | |
| 70 | + | |
| 71 | + if ( file_exists( $this->plugin_dir . $new_path ) ) { | |
| 72 | + return $new_path; | |
| 73 | + } | |
| 74 | + } | |
| 75 | + | |
| 76 | + $new_path = $this->subpath() . $resource_name . '-new.' . $resource_type; | |
| 77 | + if ( file_exists( $this->plugin_dir . $new_path ) ) { | |
| 78 | + return $new_path; | |
| 79 | + } | |
| 80 | + } | |
| 81 | + | |
| 82 | + $path = $this->subpath(); | |
| 83 | + | |
| 84 | + if ( $resource_type == 'scss' ) { | |
| 85 | + $resource_type = 'css'; | |
| 86 | + } | |
| 87 | + | |
| 88 | + return $path . $resource_name . '.' . $resource_type; | |
| 89 | + } | |
| 90 | + | |
| 91 | + private function subpath() { | |
| 92 | + return 'layouts/' . $this->layout_type . '/' . $this->layout_id . '/'; | |
| 93 | + } | |
| 94 | + | |
| 95 | + private function common_path() { | |
| 96 | + return 'layouts/common/'; | |
| 97 | + } | |
| 98 | +} | |