@@ -15,12 +15,12 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | 17 | if ( ! defined( 'ABSPATH' ) ) { |
| 18 | - exit; |
|
| 18 | + exit; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | if ( ! class_exists( 'WP_Super_Duper' ) ) { |
| 22 | - // include the class if needed |
|
| 23 | - include_once( dirname( __FILE__ ) . "/wp-super-duper.php" ); |
|
| 22 | + // include the class if needed |
|
| 23 | + include_once( dirname( __FILE__ ) . "/wp-super-duper.php" ); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /* |
@@ -14,21 +14,21 @@ |
||
| 14 | 14 | * Tested up to: 5.3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 17 | +if (!defined('ABSPATH')) { |
|
| 18 | 18 | exit; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | -if ( ! class_exists( 'WP_Super_Duper' ) ) { |
|
| 21 | +if (!class_exists('WP_Super_Duper')) { |
|
| 22 | 22 | // include the class if needed |
| 23 | - include_once( dirname( __FILE__ ) . "/wp-super-duper.php" ); |
|
| 23 | + include_once(dirname(__FILE__) . "/wp-super-duper.php"); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /* |
| 27 | 27 | * Hello world example. |
| 28 | 28 | */ |
| 29 | -include_once( dirname( __FILE__ ) . "/hello-world.php" ); |
|
| 29 | +include_once(dirname(__FILE__) . "/hello-world.php"); |
|
| 30 | 30 | |
| 31 | 31 | /* |
| 32 | 32 | * Map example. |
| 33 | 33 | */ |
| 34 | -include_once( dirname( __FILE__ ) . "/map.php" ); |
|
| 34 | +include_once(dirname(__FILE__) . "/map.php"); |
|
@@ -3,241 +3,241 @@ |
||
| 3 | 3 | class SD_Map extends WP_Super_Duper { |
| 4 | 4 | |
| 5 | 5 | |
| 6 | - public $arguments; |
|
| 7 | - |
|
| 8 | - /** |
|
| 9 | - * Sets up the widgets name etc |
|
| 10 | - */ |
|
| 11 | - public function __construct() { |
|
| 12 | - |
|
| 13 | - $options = array( |
|
| 14 | - 'textdomain' => 'super-duper', |
|
| 15 | - // textdomain of the plugin/theme (used to prefix the Gutenberg block) |
|
| 16 | - 'block-icon' => 'admin-site', |
|
| 17 | - // Dash icon name for the block: https://developer.wordpress.org/resource/dashicons/#arrow-right |
|
| 18 | - 'block-category' => 'widgets', |
|
| 19 | - // the category for the block, 'common', 'formatting', 'layout', 'widgets', 'embed'. |
|
| 20 | - 'block-keywords' => "['map','super','google']", |
|
| 21 | - // used in the block search, MAX 3 |
|
| 22 | - 'block-output' => array( // the block visual output elements as an array |
|
| 23 | - array( |
|
| 24 | - 'element' => 'p', |
|
| 25 | - 'content' => __('A Google API key is required to use this block, we recommend installing our plugin which makes it easy and sets it globally, or you can set a key in the block settings sidebar: ','super-duper'), |
|
| 26 | - //'element_require' => '"1"=='.get_option( 'rgmk_google_map_api_key', '"0"') ? '"0"' : '"1"', |
|
| 27 | - 'element_require' => get_option( 'rgmk_google_map_api_key', false) ? '1==0' : '1==1 && [%api_key%]==""', |
|
| 28 | - ), |
|
| 29 | - array( |
|
| 30 | - 'element' => 'a', |
|
| 31 | - 'content' => __('API KEY for Google Maps','super-duper'), |
|
| 32 | - 'element_require' => get_option( 'rgmk_google_map_api_key', false) ? '1==0' : '1==1 && [%api_key%]==""', |
|
| 33 | - 'href' => 'https://wordpress.org/plugins/api-key-for-google-maps/', |
|
| 34 | - ), |
|
| 35 | - array( |
|
| 36 | - 'element' => 'img', |
|
| 37 | - 'class' => '[%className%]', |
|
| 38 | - //'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%] |
|
| 39 | - 'element_require' => '[%type%]=="image"', |
|
| 40 | - 'src' => get_option( 'rgmk_google_map_api_key', false) ? "https://maps.googleapis.com/maps/api/staticmap?center=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&size=[%static_width%]x[%static_height%]&key=".get_option( 'rgmk_google_map_api_key') : "https://maps.googleapis.com/maps/api/staticmap?center=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&size=[%static_width%]x[%static_height%]&key=[%api_key%]" |
|
| 41 | - ), |
|
| 42 | - array( |
|
| 43 | - 'element' => 'div', |
|
| 44 | - 'class' => 'sd-map-iframe-cover', |
|
| 45 | - 'style' => '{overflow:"hidden", position:"relative"}', |
|
| 46 | - array( |
|
| 47 | - 'element' => 'iframe', |
|
| 48 | - 'title' => __( 'Placeholderx', 'super-duper' ), |
|
| 49 | - 'class' => '[%className%]', |
|
| 50 | - 'width' => '[%width%]', |
|
| 51 | - 'height' => '[%height%]', |
|
| 52 | - 'frameborder' => '0', |
|
| 53 | - 'allowfullscreen' => 'true', |
|
| 54 | - 'style' => '{border:0}', |
|
| 55 | - 'element_require' => '[%type%]!="image"', |
|
| 56 | - 'src' => get_option( 'rgmk_google_map_api_key', false) ? "https://www.google.com/maps/embed/v1/[%type%]?q=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&key=".get_option( 'rgmk_google_map_api_key') : "https://www.google.com/maps/embed/v1/[%type%]?q=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&key=[%api_key%]" |
|
| 57 | - ), |
|
| 58 | - ), |
|
| 59 | - array( |
|
| 60 | - 'element' => 'style', |
|
| 61 | - 'content' => '.sd-map-iframe-cover:hover:before {background: #4a4a4a88; content: "'.__("Click here, Settings are in the block settings sidebar","super-duper").'";} .sd-map-iframe-cover:before{cursor: pointer; content: ""; width: 100%; height: 100%; position: absolute; top: 0; bottom: 0;padding-top: 33%; text-align: center; color: #fff; font-size: 20px; font-weight: bold;}', |
|
| 62 | - 'element_require' => '[%type%]!="image"', |
|
| 63 | - ), |
|
| 64 | - ), |
|
| 65 | - 'class_name' => __CLASS__, |
|
| 66 | - // The calling class name |
|
| 67 | - 'base_id' => 'sd_map', |
|
| 68 | - // this is used as the widget id and the shortcode id. |
|
| 69 | - 'name' => __( 'Map', 'super-duper' ), |
|
| 70 | - // the name of the widget/block |
|
| 71 | - 'widget_ops' => array( |
|
| 72 | - 'classname' => 'sd-map-class', |
|
| 73 | - // widget class |
|
| 74 | - 'description' => esc_html__( 'This is an example that will take a text parameter and output it after `Hello:`.', 'hello-world' ), |
|
| 75 | - // widget description |
|
| 76 | - ), |
|
| 77 | - 'arguments' => array( // these are the arguments that will be used in the widget, shortcode and block settings. |
|
| 78 | - 'type' => array( |
|
| 79 | - 'title' => __('Map Type:', 'geodirectory'), |
|
| 80 | - 'desc' => __('Select the map type to use.', 'geodirectory'), |
|
| 81 | - 'type' => 'select', |
|
| 82 | - 'options' => array( |
|
| 83 | - "image" => __('Static Image', 'geodirectory'), |
|
| 84 | - "place" => __('Place', 'geodirectory'), |
|
| 6 | + public $arguments; |
|
| 7 | + |
|
| 8 | + /** |
|
| 9 | + * Sets up the widgets name etc |
|
| 10 | + */ |
|
| 11 | + public function __construct() { |
|
| 12 | + |
|
| 13 | + $options = array( |
|
| 14 | + 'textdomain' => 'super-duper', |
|
| 15 | + // textdomain of the plugin/theme (used to prefix the Gutenberg block) |
|
| 16 | + 'block-icon' => 'admin-site', |
|
| 17 | + // Dash icon name for the block: https://developer.wordpress.org/resource/dashicons/#arrow-right |
|
| 18 | + 'block-category' => 'widgets', |
|
| 19 | + // the category for the block, 'common', 'formatting', 'layout', 'widgets', 'embed'. |
|
| 20 | + 'block-keywords' => "['map','super','google']", |
|
| 21 | + // used in the block search, MAX 3 |
|
| 22 | + 'block-output' => array( // the block visual output elements as an array |
|
| 23 | + array( |
|
| 24 | + 'element' => 'p', |
|
| 25 | + 'content' => __('A Google API key is required to use this block, we recommend installing our plugin which makes it easy and sets it globally, or you can set a key in the block settings sidebar: ','super-duper'), |
|
| 26 | + //'element_require' => '"1"=='.get_option( 'rgmk_google_map_api_key', '"0"') ? '"0"' : '"1"', |
|
| 27 | + 'element_require' => get_option( 'rgmk_google_map_api_key', false) ? '1==0' : '1==1 && [%api_key%]==""', |
|
| 28 | + ), |
|
| 29 | + array( |
|
| 30 | + 'element' => 'a', |
|
| 31 | + 'content' => __('API KEY for Google Maps','super-duper'), |
|
| 32 | + 'element_require' => get_option( 'rgmk_google_map_api_key', false) ? '1==0' : '1==1 && [%api_key%]==""', |
|
| 33 | + 'href' => 'https://wordpress.org/plugins/api-key-for-google-maps/', |
|
| 34 | + ), |
|
| 35 | + array( |
|
| 36 | + 'element' => 'img', |
|
| 37 | + 'class' => '[%className%]', |
|
| 38 | + //'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%] |
|
| 39 | + 'element_require' => '[%type%]=="image"', |
|
| 40 | + 'src' => get_option( 'rgmk_google_map_api_key', false) ? "https://maps.googleapis.com/maps/api/staticmap?center=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&size=[%static_width%]x[%static_height%]&key=".get_option( 'rgmk_google_map_api_key') : "https://maps.googleapis.com/maps/api/staticmap?center=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&size=[%static_width%]x[%static_height%]&key=[%api_key%]" |
|
| 41 | + ), |
|
| 42 | + array( |
|
| 43 | + 'element' => 'div', |
|
| 44 | + 'class' => 'sd-map-iframe-cover', |
|
| 45 | + 'style' => '{overflow:"hidden", position:"relative"}', |
|
| 46 | + array( |
|
| 47 | + 'element' => 'iframe', |
|
| 48 | + 'title' => __( 'Placeholderx', 'super-duper' ), |
|
| 49 | + 'class' => '[%className%]', |
|
| 50 | + 'width' => '[%width%]', |
|
| 51 | + 'height' => '[%height%]', |
|
| 52 | + 'frameborder' => '0', |
|
| 53 | + 'allowfullscreen' => 'true', |
|
| 54 | + 'style' => '{border:0}', |
|
| 55 | + 'element_require' => '[%type%]!="image"', |
|
| 56 | + 'src' => get_option( 'rgmk_google_map_api_key', false) ? "https://www.google.com/maps/embed/v1/[%type%]?q=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&key=".get_option( 'rgmk_google_map_api_key') : "https://www.google.com/maps/embed/v1/[%type%]?q=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&key=[%api_key%]" |
|
| 57 | + ), |
|
| 58 | + ), |
|
| 59 | + array( |
|
| 60 | + 'element' => 'style', |
|
| 61 | + 'content' => '.sd-map-iframe-cover:hover:before {background: #4a4a4a88; content: "'.__("Click here, Settings are in the block settings sidebar","super-duper").'";} .sd-map-iframe-cover:before{cursor: pointer; content: ""; width: 100%; height: 100%; position: absolute; top: 0; bottom: 0;padding-top: 33%; text-align: center; color: #fff; font-size: 20px; font-weight: bold;}', |
|
| 62 | + 'element_require' => '[%type%]!="image"', |
|
| 63 | + ), |
|
| 64 | + ), |
|
| 65 | + 'class_name' => __CLASS__, |
|
| 66 | + // The calling class name |
|
| 67 | + 'base_id' => 'sd_map', |
|
| 68 | + // this is used as the widget id and the shortcode id. |
|
| 69 | + 'name' => __( 'Map', 'super-duper' ), |
|
| 70 | + // the name of the widget/block |
|
| 71 | + 'widget_ops' => array( |
|
| 72 | + 'classname' => 'sd-map-class', |
|
| 73 | + // widget class |
|
| 74 | + 'description' => esc_html__( 'This is an example that will take a text parameter and output it after `Hello:`.', 'hello-world' ), |
|
| 75 | + // widget description |
|
| 76 | + ), |
|
| 77 | + 'arguments' => array( // these are the arguments that will be used in the widget, shortcode and block settings. |
|
| 78 | + 'type' => array( |
|
| 79 | + 'title' => __('Map Type:', 'geodirectory'), |
|
| 80 | + 'desc' => __('Select the map type to use.', 'geodirectory'), |
|
| 81 | + 'type' => 'select', |
|
| 82 | + 'options' => array( |
|
| 83 | + "image" => __('Static Image', 'geodirectory'), |
|
| 84 | + "place" => __('Place', 'geodirectory'), |
|
| 85 | 85 | // "directions" => __('Directions', 'geodirectory'), |
| 86 | 86 | // "search" => __('Search', 'geodirectory'), |
| 87 | 87 | // "view" => __('View', 'geodirectory'), |
| 88 | 88 | // "streetview" => __('Streetview', 'geodirectory'), |
| 89 | - ), |
|
| 90 | - 'default' => 'image', |
|
| 91 | - 'desc_tip' => true, |
|
| 92 | - 'advanced' => false |
|
| 93 | - ), |
|
| 94 | - 'location' => array( |
|
| 95 | - 'type' => 'text', |
|
| 96 | - 'title' => __( 'Location:', 'geodirectory' ), |
|
| 97 | - 'desc' => __( 'Enter the location to show on the map, place, city, zip code or GPS.', 'geodirectory' ), |
|
| 98 | - 'placeholder' => 'Place, city, zip code or GPS', |
|
| 99 | - 'desc_tip' => true, |
|
| 100 | - 'default' => 'Ireland', |
|
| 101 | - 'advanced' => false |
|
| 102 | - ), |
|
| 103 | - 'static_width' => array( |
|
| 104 | - 'type' => 'number', |
|
| 105 | - 'title' => __( 'Width:', 'geodirectory' ), |
|
| 106 | - 'desc' => __( 'This is the width of the map, for static maps you can only use px values.', 'geodirectory' ), |
|
| 107 | - 'placeholder' => '600', |
|
| 108 | - 'desc_tip' => true, |
|
| 109 | - 'default' => '600', |
|
| 110 | - 'custom_attributes' => array( |
|
| 111 | - 'max' => '2000', |
|
| 112 | - 'min' => '100', |
|
| 113 | - ), |
|
| 114 | - 'element_require' => '[%type%]=="image"', |
|
| 115 | - 'advanced' => false |
|
| 116 | - ), |
|
| 117 | - 'static_height' => array( |
|
| 118 | - 'type' => 'number', |
|
| 119 | - 'title' => __( 'Height:', 'geodirectory' ), |
|
| 120 | - 'desc' => __( 'This is the height of the map, for static maps you can only use px values.', 'geodirectory' ), |
|
| 121 | - 'placeholder' => '400', |
|
| 122 | - 'desc_tip' => true, |
|
| 123 | - 'default' => '400', |
|
| 124 | - 'custom_attributes' => array( |
|
| 125 | - 'max' => '2000', |
|
| 126 | - 'min' => '100', |
|
| 127 | - 'required' => 'required', |
|
| 128 | - ), |
|
| 129 | - 'element_require' => '[%type%]=="image"', |
|
| 130 | - 'advanced' => false |
|
| 131 | - ), |
|
| 132 | - 'width' => array( |
|
| 133 | - 'type' => 'text', |
|
| 134 | - 'title' => __( 'Width:', 'geodirectory' ), |
|
| 135 | - 'desc' => __( 'This is the width of the map, you can use % or px here.', 'geodirectory' ), |
|
| 136 | - 'placeholder' => '100%', |
|
| 137 | - 'desc_tip' => true, |
|
| 138 | - 'default' => '100%', |
|
| 139 | - 'element_require' => '[%type%]!="image"', |
|
| 140 | - 'advanced' => false |
|
| 141 | - ), |
|
| 142 | - 'height' => array( |
|
| 143 | - 'type' => 'text', |
|
| 144 | - 'title' => __( 'Height:', 'geodirectory' ), |
|
| 145 | - 'desc' => __( 'This is the height of the map, you can use %, px or vh here.', 'geodirectory' ), |
|
| 146 | - 'placeholder' => '425px', |
|
| 147 | - 'desc_tip' => true, |
|
| 148 | - 'default' => '425px', |
|
| 149 | - 'element_require' => '[%type%]!="image"', |
|
| 150 | - 'advanced' => false |
|
| 151 | - ), |
|
| 152 | - 'maptype' => array( |
|
| 153 | - 'type' => 'select', |
|
| 154 | - 'title' => __( 'Mapview:', 'geodirectory' ), |
|
| 155 | - 'desc' => __( 'This is the type of map view that will be used by default.', 'geodirectory' ), |
|
| 156 | - 'options' => array( |
|
| 157 | - "roadmap" => __( 'Road Map', 'geodirectory' ), |
|
| 158 | - "satellite" => __( 'Satellite Map', 'geodirectory' ), |
|
| 89 | + ), |
|
| 90 | + 'default' => 'image', |
|
| 91 | + 'desc_tip' => true, |
|
| 92 | + 'advanced' => false |
|
| 93 | + ), |
|
| 94 | + 'location' => array( |
|
| 95 | + 'type' => 'text', |
|
| 96 | + 'title' => __( 'Location:', 'geodirectory' ), |
|
| 97 | + 'desc' => __( 'Enter the location to show on the map, place, city, zip code or GPS.', 'geodirectory' ), |
|
| 98 | + 'placeholder' => 'Place, city, zip code or GPS', |
|
| 99 | + 'desc_tip' => true, |
|
| 100 | + 'default' => 'Ireland', |
|
| 101 | + 'advanced' => false |
|
| 102 | + ), |
|
| 103 | + 'static_width' => array( |
|
| 104 | + 'type' => 'number', |
|
| 105 | + 'title' => __( 'Width:', 'geodirectory' ), |
|
| 106 | + 'desc' => __( 'This is the width of the map, for static maps you can only use px values.', 'geodirectory' ), |
|
| 107 | + 'placeholder' => '600', |
|
| 108 | + 'desc_tip' => true, |
|
| 109 | + 'default' => '600', |
|
| 110 | + 'custom_attributes' => array( |
|
| 111 | + 'max' => '2000', |
|
| 112 | + 'min' => '100', |
|
| 113 | + ), |
|
| 114 | + 'element_require' => '[%type%]=="image"', |
|
| 115 | + 'advanced' => false |
|
| 116 | + ), |
|
| 117 | + 'static_height' => array( |
|
| 118 | + 'type' => 'number', |
|
| 119 | + 'title' => __( 'Height:', 'geodirectory' ), |
|
| 120 | + 'desc' => __( 'This is the height of the map, for static maps you can only use px values.', 'geodirectory' ), |
|
| 121 | + 'placeholder' => '400', |
|
| 122 | + 'desc_tip' => true, |
|
| 123 | + 'default' => '400', |
|
| 124 | + 'custom_attributes' => array( |
|
| 125 | + 'max' => '2000', |
|
| 126 | + 'min' => '100', |
|
| 127 | + 'required' => 'required', |
|
| 128 | + ), |
|
| 129 | + 'element_require' => '[%type%]=="image"', |
|
| 130 | + 'advanced' => false |
|
| 131 | + ), |
|
| 132 | + 'width' => array( |
|
| 133 | + 'type' => 'text', |
|
| 134 | + 'title' => __( 'Width:', 'geodirectory' ), |
|
| 135 | + 'desc' => __( 'This is the width of the map, you can use % or px here.', 'geodirectory' ), |
|
| 136 | + 'placeholder' => '100%', |
|
| 137 | + 'desc_tip' => true, |
|
| 138 | + 'default' => '100%', |
|
| 139 | + 'element_require' => '[%type%]!="image"', |
|
| 140 | + 'advanced' => false |
|
| 141 | + ), |
|
| 142 | + 'height' => array( |
|
| 143 | + 'type' => 'text', |
|
| 144 | + 'title' => __( 'Height:', 'geodirectory' ), |
|
| 145 | + 'desc' => __( 'This is the height of the map, you can use %, px or vh here.', 'geodirectory' ), |
|
| 146 | + 'placeholder' => '425px', |
|
| 147 | + 'desc_tip' => true, |
|
| 148 | + 'default' => '425px', |
|
| 149 | + 'element_require' => '[%type%]!="image"', |
|
| 150 | + 'advanced' => false |
|
| 151 | + ), |
|
| 152 | + 'maptype' => array( |
|
| 153 | + 'type' => 'select', |
|
| 154 | + 'title' => __( 'Mapview:', 'geodirectory' ), |
|
| 155 | + 'desc' => __( 'This is the type of map view that will be used by default.', 'geodirectory' ), |
|
| 156 | + 'options' => array( |
|
| 157 | + "roadmap" => __( 'Road Map', 'geodirectory' ), |
|
| 158 | + "satellite" => __( 'Satellite Map', 'geodirectory' ), |
|
| 159 | 159 | // "hybrid" => __( 'Hybrid Map', 'geodirectory' ), |
| 160 | 160 | // "terrain" => __( 'Terrain Map', 'geodirectory' ), |
| 161 | - ), |
|
| 162 | - 'desc_tip' => true, |
|
| 163 | - 'default' => 'roadmap', |
|
| 164 | - 'advanced' => true |
|
| 165 | - ), |
|
| 166 | - 'zoom' => array( |
|
| 167 | - 'type' => 'select', |
|
| 168 | - 'title' => __( 'Zoom level:', 'geodirectory' ), |
|
| 169 | - 'desc' => __( 'This is the zoom level of the map, `auto` is recommended.', 'geodirectory' ), |
|
| 170 | - 'options' => range( 1, 19 ), |
|
| 171 | - 'placeholder' => '', |
|
| 172 | - 'desc_tip' => true, |
|
| 173 | - 'default' => '7', |
|
| 174 | - 'advanced' => true |
|
| 175 | - ), |
|
| 176 | - 'api_key' => array( |
|
| 177 | - 'type' => 'text', |
|
| 178 | - 'title' => __( 'Api Key:', 'geodirectory' ), |
|
| 179 | - 'desc' => __( 'This is the height of the map, you can use %, px or vh here.', 'geodirectory' ), |
|
| 180 | - 'placeholder' => '', |
|
| 181 | - 'desc_tip' => true, |
|
| 182 | - 'default' => '', |
|
| 183 | - 'element_require' => get_option( 'rgmk_google_map_api_key', false) ? '1==0' : '1==1', |
|
| 184 | - 'advanced' => false |
|
| 185 | - ), |
|
| 186 | - ) |
|
| 187 | - ); |
|
| 188 | - |
|
| 189 | - parent::__construct( $options ); |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - |
|
| 193 | - /** |
|
| 194 | - * This is the output function for the widget, shortcode and block (front end). |
|
| 195 | - * |
|
| 196 | - * @param array $args The arguments values. |
|
| 197 | - * @param array $widget_args The widget arguments when used. |
|
| 198 | - * @param string $content The shortcode content argument |
|
| 199 | - * |
|
| 200 | - * @return string |
|
| 201 | - */ |
|
| 202 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 203 | - |
|
| 204 | - // options |
|
| 205 | - $defaults = array( |
|
| 206 | - 'type' => 'image', // image, place |
|
| 207 | - 'location' => 'Ireland', |
|
| 208 | - 'static_width' => '600', |
|
| 209 | - 'static_height' => '400', |
|
| 210 | - 'width'=> '100%', |
|
| 211 | - 'height'=> '425px', |
|
| 212 | - 'maptype' => 'roadmap', |
|
| 213 | - 'zoom' => '7', |
|
| 214 | - 'api_key' => 'AIzaSyBK3ZcmK0ljxl5agNyJNQh_G24Thq1btuE', |
|
| 215 | - ); |
|
| 216 | - |
|
| 217 | - /** |
|
| 218 | - * Parse incoming $args into an array and merge it with $defaults |
|
| 219 | - */ |
|
| 220 | - $args = wp_parse_args($args, $defaults ); |
|
| 221 | - |
|
| 222 | - $output = ''; |
|
| 223 | - |
|
| 224 | - |
|
| 225 | - // check if we have a global API key |
|
| 226 | - $args['api_key'] = get_option( 'rgmk_google_map_api_key', false ) ? get_option( 'rgmk_google_map_api_key' ) : $args['api_key']; |
|
| 227 | - |
|
| 228 | - if($args['type']=='image'){ |
|
| 229 | - $output .= "<img src='https://maps.googleapis.com/maps/api/staticmap?center=".esc_attr($args['location'])."&maptype=".esc_attr($args['maptype'])."&zoom=".esc_attr($args['zoom'])."&size=".esc_attr($args['static_width'])."x".esc_attr($args['static_height'])."&key=".esc_attr($args['api_key'])."' />"; |
|
| 230 | - }else{ |
|
| 231 | - $output .= "<iframe width='".esc_attr($args['width'])."' height='".esc_attr($args['height'])."' frameborder='0' allowfullscreen style='border:0;' src='https://www.google.com/maps/embed/v1/".esc_attr($args['type'])."?q=".esc_attr($args['location'])."&maptype=".esc_attr($args['maptype'])."&zoom=".esc_attr($args['zoom'])."&key=".esc_attr($args['api_key'])."' ></iframe> "; |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - return $output; |
|
| 235 | - |
|
| 236 | - } |
|
| 161 | + ), |
|
| 162 | + 'desc_tip' => true, |
|
| 163 | + 'default' => 'roadmap', |
|
| 164 | + 'advanced' => true |
|
| 165 | + ), |
|
| 166 | + 'zoom' => array( |
|
| 167 | + 'type' => 'select', |
|
| 168 | + 'title' => __( 'Zoom level:', 'geodirectory' ), |
|
| 169 | + 'desc' => __( 'This is the zoom level of the map, `auto` is recommended.', 'geodirectory' ), |
|
| 170 | + 'options' => range( 1, 19 ), |
|
| 171 | + 'placeholder' => '', |
|
| 172 | + 'desc_tip' => true, |
|
| 173 | + 'default' => '7', |
|
| 174 | + 'advanced' => true |
|
| 175 | + ), |
|
| 176 | + 'api_key' => array( |
|
| 177 | + 'type' => 'text', |
|
| 178 | + 'title' => __( 'Api Key:', 'geodirectory' ), |
|
| 179 | + 'desc' => __( 'This is the height of the map, you can use %, px or vh here.', 'geodirectory' ), |
|
| 180 | + 'placeholder' => '', |
|
| 181 | + 'desc_tip' => true, |
|
| 182 | + 'default' => '', |
|
| 183 | + 'element_require' => get_option( 'rgmk_google_map_api_key', false) ? '1==0' : '1==1', |
|
| 184 | + 'advanced' => false |
|
| 185 | + ), |
|
| 186 | + ) |
|
| 187 | + ); |
|
| 188 | + |
|
| 189 | + parent::__construct( $options ); |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + |
|
| 193 | + /** |
|
| 194 | + * This is the output function for the widget, shortcode and block (front end). |
|
| 195 | + * |
|
| 196 | + * @param array $args The arguments values. |
|
| 197 | + * @param array $widget_args The widget arguments when used. |
|
| 198 | + * @param string $content The shortcode content argument |
|
| 199 | + * |
|
| 200 | + * @return string |
|
| 201 | + */ |
|
| 202 | + public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 203 | + |
|
| 204 | + // options |
|
| 205 | + $defaults = array( |
|
| 206 | + 'type' => 'image', // image, place |
|
| 207 | + 'location' => 'Ireland', |
|
| 208 | + 'static_width' => '600', |
|
| 209 | + 'static_height' => '400', |
|
| 210 | + 'width'=> '100%', |
|
| 211 | + 'height'=> '425px', |
|
| 212 | + 'maptype' => 'roadmap', |
|
| 213 | + 'zoom' => '7', |
|
| 214 | + 'api_key' => 'AIzaSyBK3ZcmK0ljxl5agNyJNQh_G24Thq1btuE', |
|
| 215 | + ); |
|
| 216 | + |
|
| 217 | + /** |
|
| 218 | + * Parse incoming $args into an array and merge it with $defaults |
|
| 219 | + */ |
|
| 220 | + $args = wp_parse_args($args, $defaults ); |
|
| 221 | + |
|
| 222 | + $output = ''; |
|
| 223 | + |
|
| 224 | + |
|
| 225 | + // check if we have a global API key |
|
| 226 | + $args['api_key'] = get_option( 'rgmk_google_map_api_key', false ) ? get_option( 'rgmk_google_map_api_key' ) : $args['api_key']; |
|
| 227 | + |
|
| 228 | + if($args['type']=='image'){ |
|
| 229 | + $output .= "<img src='https://maps.googleapis.com/maps/api/staticmap?center=".esc_attr($args['location'])."&maptype=".esc_attr($args['maptype'])."&zoom=".esc_attr($args['zoom'])."&size=".esc_attr($args['static_width'])."x".esc_attr($args['static_height'])."&key=".esc_attr($args['api_key'])."' />"; |
|
| 230 | + }else{ |
|
| 231 | + $output .= "<iframe width='".esc_attr($args['width'])."' height='".esc_attr($args['height'])."' frameborder='0' allowfullscreen style='border:0;' src='https://www.google.com/maps/embed/v1/".esc_attr($args['type'])."?q=".esc_attr($args['location'])."&maptype=".esc_attr($args['maptype'])."&zoom=".esc_attr($args['zoom'])."&key=".esc_attr($args['api_key'])."' ></iframe> "; |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + return $output; |
|
| 235 | + |
|
| 236 | + } |
|
| 237 | 237 | |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | // register it. |
| 241 | 241 | add_action( 'widgets_init', function () { |
| 242 | - register_widget( 'SD_Map' ); |
|
| 242 | + register_widget( 'SD_Map' ); |
|
| 243 | 243 | } ); |
@@ -22,14 +22,14 @@ discard block |
||
| 22 | 22 | 'block-output' => array( // the block visual output elements as an array |
| 23 | 23 | array( |
| 24 | 24 | 'element' => 'p', |
| 25 | - 'content' => __('A Google API key is required to use this block, we recommend installing our plugin which makes it easy and sets it globally, or you can set a key in the block settings sidebar: ','super-duper'), |
|
| 25 | + 'content' => __('A Google API key is required to use this block, we recommend installing our plugin which makes it easy and sets it globally, or you can set a key in the block settings sidebar: ', 'super-duper'), |
|
| 26 | 26 | //'element_require' => '"1"=='.get_option( 'rgmk_google_map_api_key', '"0"') ? '"0"' : '"1"', |
| 27 | - 'element_require' => get_option( 'rgmk_google_map_api_key', false) ? '1==0' : '1==1 && [%api_key%]==""', |
|
| 27 | + 'element_require' => get_option('rgmk_google_map_api_key', false) ? '1==0' : '1==1 && [%api_key%]==""', |
|
| 28 | 28 | ), |
| 29 | 29 | array( |
| 30 | 30 | 'element' => 'a', |
| 31 | - 'content' => __('API KEY for Google Maps','super-duper'), |
|
| 32 | - 'element_require' => get_option( 'rgmk_google_map_api_key', false) ? '1==0' : '1==1 && [%api_key%]==""', |
|
| 31 | + 'content' => __('API KEY for Google Maps', 'super-duper'), |
|
| 32 | + 'element_require' => get_option('rgmk_google_map_api_key', false) ? '1==0' : '1==1 && [%api_key%]==""', |
|
| 33 | 33 | 'href' => 'https://wordpress.org/plugins/api-key-for-google-maps/', |
| 34 | 34 | ), |
| 35 | 35 | array( |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | 'class' => '[%className%]', |
| 38 | 38 | //'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%] |
| 39 | 39 | 'element_require' => '[%type%]=="image"', |
| 40 | - 'src' => get_option( 'rgmk_google_map_api_key', false) ? "https://maps.googleapis.com/maps/api/staticmap?center=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&size=[%static_width%]x[%static_height%]&key=".get_option( 'rgmk_google_map_api_key') : "https://maps.googleapis.com/maps/api/staticmap?center=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&size=[%static_width%]x[%static_height%]&key=[%api_key%]" |
|
| 40 | + 'src' => get_option('rgmk_google_map_api_key', false) ? "https://maps.googleapis.com/maps/api/staticmap?center=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&size=[%static_width%]x[%static_height%]&key=" . get_option('rgmk_google_map_api_key') : "https://maps.googleapis.com/maps/api/staticmap?center=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&size=[%static_width%]x[%static_height%]&key=[%api_key%]" |
|
| 41 | 41 | ), |
| 42 | 42 | array( |
| 43 | 43 | 'element' => 'div', |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | 'style' => '{overflow:"hidden", position:"relative"}', |
| 46 | 46 | array( |
| 47 | 47 | 'element' => 'iframe', |
| 48 | - 'title' => __( 'Placeholderx', 'super-duper' ), |
|
| 48 | + 'title' => __('Placeholderx', 'super-duper'), |
|
| 49 | 49 | 'class' => '[%className%]', |
| 50 | 50 | 'width' => '[%width%]', |
| 51 | 51 | 'height' => '[%height%]', |
@@ -53,12 +53,12 @@ discard block |
||
| 53 | 53 | 'allowfullscreen' => 'true', |
| 54 | 54 | 'style' => '{border:0}', |
| 55 | 55 | 'element_require' => '[%type%]!="image"', |
| 56 | - 'src' => get_option( 'rgmk_google_map_api_key', false) ? "https://www.google.com/maps/embed/v1/[%type%]?q=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&key=".get_option( 'rgmk_google_map_api_key') : "https://www.google.com/maps/embed/v1/[%type%]?q=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&key=[%api_key%]" |
|
| 56 | + 'src' => get_option('rgmk_google_map_api_key', false) ? "https://www.google.com/maps/embed/v1/[%type%]?q=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&key=" . get_option('rgmk_google_map_api_key') : "https://www.google.com/maps/embed/v1/[%type%]?q=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&key=[%api_key%]" |
|
| 57 | 57 | ), |
| 58 | 58 | ), |
| 59 | 59 | array( |
| 60 | 60 | 'element' => 'style', |
| 61 | - 'content' => '.sd-map-iframe-cover:hover:before {background: #4a4a4a88; content: "'.__("Click here, Settings are in the block settings sidebar","super-duper").'";} .sd-map-iframe-cover:before{cursor: pointer; content: ""; width: 100%; height: 100%; position: absolute; top: 0; bottom: 0;padding-top: 33%; text-align: center; color: #fff; font-size: 20px; font-weight: bold;}', |
|
| 61 | + 'content' => '.sd-map-iframe-cover:hover:before {background: #4a4a4a88; content: "' . __("Click here, Settings are in the block settings sidebar", "super-duper") . '";} .sd-map-iframe-cover:before{cursor: pointer; content: ""; width: 100%; height: 100%; position: absolute; top: 0; bottom: 0;padding-top: 33%; text-align: center; color: #fff; font-size: 20px; font-weight: bold;}', |
|
| 62 | 62 | 'element_require' => '[%type%]!="image"', |
| 63 | 63 | ), |
| 64 | 64 | ), |
@@ -66,12 +66,12 @@ discard block |
||
| 66 | 66 | // The calling class name |
| 67 | 67 | 'base_id' => 'sd_map', |
| 68 | 68 | // this is used as the widget id and the shortcode id. |
| 69 | - 'name' => __( 'Map', 'super-duper' ), |
|
| 69 | + 'name' => __('Map', 'super-duper'), |
|
| 70 | 70 | // the name of the widget/block |
| 71 | 71 | 'widget_ops' => array( |
| 72 | 72 | 'classname' => 'sd-map-class', |
| 73 | 73 | // widget class |
| 74 | - 'description' => esc_html__( 'This is an example that will take a text parameter and output it after `Hello:`.', 'hello-world' ), |
|
| 74 | + 'description' => esc_html__('This is an example that will take a text parameter and output it after `Hello:`.', 'hello-world'), |
|
| 75 | 75 | // widget description |
| 76 | 76 | ), |
| 77 | 77 | 'arguments' => array( // these are the arguments that will be used in the widget, shortcode and block settings. |
@@ -93,8 +93,8 @@ discard block |
||
| 93 | 93 | ), |
| 94 | 94 | 'location' => array( |
| 95 | 95 | 'type' => 'text', |
| 96 | - 'title' => __( 'Location:', 'geodirectory' ), |
|
| 97 | - 'desc' => __( 'Enter the location to show on the map, place, city, zip code or GPS.', 'geodirectory' ), |
|
| 96 | + 'title' => __('Location:', 'geodirectory'), |
|
| 97 | + 'desc' => __('Enter the location to show on the map, place, city, zip code or GPS.', 'geodirectory'), |
|
| 98 | 98 | 'placeholder' => 'Place, city, zip code or GPS', |
| 99 | 99 | 'desc_tip' => true, |
| 100 | 100 | 'default' => 'Ireland', |
@@ -102,8 +102,8 @@ discard block |
||
| 102 | 102 | ), |
| 103 | 103 | 'static_width' => array( |
| 104 | 104 | 'type' => 'number', |
| 105 | - 'title' => __( 'Width:', 'geodirectory' ), |
|
| 106 | - 'desc' => __( 'This is the width of the map, for static maps you can only use px values.', 'geodirectory' ), |
|
| 105 | + 'title' => __('Width:', 'geodirectory'), |
|
| 106 | + 'desc' => __('This is the width of the map, for static maps you can only use px values.', 'geodirectory'), |
|
| 107 | 107 | 'placeholder' => '600', |
| 108 | 108 | 'desc_tip' => true, |
| 109 | 109 | 'default' => '600', |
@@ -116,8 +116,8 @@ discard block |
||
| 116 | 116 | ), |
| 117 | 117 | 'static_height' => array( |
| 118 | 118 | 'type' => 'number', |
| 119 | - 'title' => __( 'Height:', 'geodirectory' ), |
|
| 120 | - 'desc' => __( 'This is the height of the map, for static maps you can only use px values.', 'geodirectory' ), |
|
| 119 | + 'title' => __('Height:', 'geodirectory'), |
|
| 120 | + 'desc' => __('This is the height of the map, for static maps you can only use px values.', 'geodirectory'), |
|
| 121 | 121 | 'placeholder' => '400', |
| 122 | 122 | 'desc_tip' => true, |
| 123 | 123 | 'default' => '400', |
@@ -131,8 +131,8 @@ discard block |
||
| 131 | 131 | ), |
| 132 | 132 | 'width' => array( |
| 133 | 133 | 'type' => 'text', |
| 134 | - 'title' => __( 'Width:', 'geodirectory' ), |
|
| 135 | - 'desc' => __( 'This is the width of the map, you can use % or px here.', 'geodirectory' ), |
|
| 134 | + 'title' => __('Width:', 'geodirectory'), |
|
| 135 | + 'desc' => __('This is the width of the map, you can use % or px here.', 'geodirectory'), |
|
| 136 | 136 | 'placeholder' => '100%', |
| 137 | 137 | 'desc_tip' => true, |
| 138 | 138 | 'default' => '100%', |
@@ -141,8 +141,8 @@ discard block |
||
| 141 | 141 | ), |
| 142 | 142 | 'height' => array( |
| 143 | 143 | 'type' => 'text', |
| 144 | - 'title' => __( 'Height:', 'geodirectory' ), |
|
| 145 | - 'desc' => __( 'This is the height of the map, you can use %, px or vh here.', 'geodirectory' ), |
|
| 144 | + 'title' => __('Height:', 'geodirectory'), |
|
| 145 | + 'desc' => __('This is the height of the map, you can use %, px or vh here.', 'geodirectory'), |
|
| 146 | 146 | 'placeholder' => '425px', |
| 147 | 147 | 'desc_tip' => true, |
| 148 | 148 | 'default' => '425px', |
@@ -151,11 +151,11 @@ discard block |
||
| 151 | 151 | ), |
| 152 | 152 | 'maptype' => array( |
| 153 | 153 | 'type' => 'select', |
| 154 | - 'title' => __( 'Mapview:', 'geodirectory' ), |
|
| 155 | - 'desc' => __( 'This is the type of map view that will be used by default.', 'geodirectory' ), |
|
| 154 | + 'title' => __('Mapview:', 'geodirectory'), |
|
| 155 | + 'desc' => __('This is the type of map view that will be used by default.', 'geodirectory'), |
|
| 156 | 156 | 'options' => array( |
| 157 | - "roadmap" => __( 'Road Map', 'geodirectory' ), |
|
| 158 | - "satellite" => __( 'Satellite Map', 'geodirectory' ), |
|
| 157 | + "roadmap" => __('Road Map', 'geodirectory'), |
|
| 158 | + "satellite" => __('Satellite Map', 'geodirectory'), |
|
| 159 | 159 | // "hybrid" => __( 'Hybrid Map', 'geodirectory' ), |
| 160 | 160 | // "terrain" => __( 'Terrain Map', 'geodirectory' ), |
| 161 | 161 | ), |
@@ -165,9 +165,9 @@ discard block |
||
| 165 | 165 | ), |
| 166 | 166 | 'zoom' => array( |
| 167 | 167 | 'type' => 'select', |
| 168 | - 'title' => __( 'Zoom level:', 'geodirectory' ), |
|
| 169 | - 'desc' => __( 'This is the zoom level of the map, `auto` is recommended.', 'geodirectory' ), |
|
| 170 | - 'options' => range( 1, 19 ), |
|
| 168 | + 'title' => __('Zoom level:', 'geodirectory'), |
|
| 169 | + 'desc' => __('This is the zoom level of the map, `auto` is recommended.', 'geodirectory'), |
|
| 170 | + 'options' => range(1, 19), |
|
| 171 | 171 | 'placeholder' => '', |
| 172 | 172 | 'desc_tip' => true, |
| 173 | 173 | 'default' => '7', |
@@ -175,18 +175,18 @@ discard block |
||
| 175 | 175 | ), |
| 176 | 176 | 'api_key' => array( |
| 177 | 177 | 'type' => 'text', |
| 178 | - 'title' => __( 'Api Key:', 'geodirectory' ), |
|
| 179 | - 'desc' => __( 'This is the height of the map, you can use %, px or vh here.', 'geodirectory' ), |
|
| 178 | + 'title' => __('Api Key:', 'geodirectory'), |
|
| 179 | + 'desc' => __('This is the height of the map, you can use %, px or vh here.', 'geodirectory'), |
|
| 180 | 180 | 'placeholder' => '', |
| 181 | 181 | 'desc_tip' => true, |
| 182 | 182 | 'default' => '', |
| 183 | - 'element_require' => get_option( 'rgmk_google_map_api_key', false) ? '1==0' : '1==1', |
|
| 183 | + 'element_require' => get_option('rgmk_google_map_api_key', false) ? '1==0' : '1==1', |
|
| 184 | 184 | 'advanced' => false |
| 185 | 185 | ), |
| 186 | 186 | ) |
| 187 | 187 | ); |
| 188 | 188 | |
| 189 | - parent::__construct( $options ); |
|
| 189 | + parent::__construct($options); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | * |
| 200 | 200 | * @return string |
| 201 | 201 | */ |
| 202 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 202 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
| 203 | 203 | |
| 204 | 204 | // options |
| 205 | 205 | $defaults = array( |
@@ -217,18 +217,18 @@ discard block |
||
| 217 | 217 | /** |
| 218 | 218 | * Parse incoming $args into an array and merge it with $defaults |
| 219 | 219 | */ |
| 220 | - $args = wp_parse_args($args, $defaults ); |
|
| 220 | + $args = wp_parse_args($args, $defaults); |
|
| 221 | 221 | |
| 222 | 222 | $output = ''; |
| 223 | 223 | |
| 224 | 224 | |
| 225 | 225 | // check if we have a global API key |
| 226 | - $args['api_key'] = get_option( 'rgmk_google_map_api_key', false ) ? get_option( 'rgmk_google_map_api_key' ) : $args['api_key']; |
|
| 226 | + $args['api_key'] = get_option('rgmk_google_map_api_key', false) ? get_option('rgmk_google_map_api_key') : $args['api_key']; |
|
| 227 | 227 | |
| 228 | - if($args['type']=='image'){ |
|
| 229 | - $output .= "<img src='https://maps.googleapis.com/maps/api/staticmap?center=".esc_attr($args['location'])."&maptype=".esc_attr($args['maptype'])."&zoom=".esc_attr($args['zoom'])."&size=".esc_attr($args['static_width'])."x".esc_attr($args['static_height'])."&key=".esc_attr($args['api_key'])."' />"; |
|
| 230 | - }else{ |
|
| 231 | - $output .= "<iframe width='".esc_attr($args['width'])."' height='".esc_attr($args['height'])."' frameborder='0' allowfullscreen style='border:0;' src='https://www.google.com/maps/embed/v1/".esc_attr($args['type'])."?q=".esc_attr($args['location'])."&maptype=".esc_attr($args['maptype'])."&zoom=".esc_attr($args['zoom'])."&key=".esc_attr($args['api_key'])."' ></iframe> "; |
|
| 228 | + if ($args['type'] == 'image') { |
|
| 229 | + $output .= "<img src='https://maps.googleapis.com/maps/api/staticmap?center=" . esc_attr($args['location']) . "&maptype=" . esc_attr($args['maptype']) . "&zoom=" . esc_attr($args['zoom']) . "&size=" . esc_attr($args['static_width']) . "x" . esc_attr($args['static_height']) . "&key=" . esc_attr($args['api_key']) . "' />"; |
|
| 230 | + } else { |
|
| 231 | + $output .= "<iframe width='" . esc_attr($args['width']) . "' height='" . esc_attr($args['height']) . "' frameborder='0' allowfullscreen style='border:0;' src='https://www.google.com/maps/embed/v1/" . esc_attr($args['type']) . "?q=" . esc_attr($args['location']) . "&maptype=" . esc_attr($args['maptype']) . "&zoom=" . esc_attr($args['zoom']) . "&key=" . esc_attr($args['api_key']) . "' ></iframe> "; |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | return $output; |
@@ -238,6 +238,6 @@ discard block |
||
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | // register it. |
| 241 | -add_action( 'widgets_init', function () { |
|
| 242 | - register_widget( 'SD_Map' ); |
|
| 241 | +add_action('widgets_init', function() { |
|
| 242 | + register_widget('SD_Map'); |
|
| 243 | 243 | } ); |
@@ -227,7 +227,7 @@ |
||
| 227 | 227 | |
| 228 | 228 | if($args['type']=='image'){ |
| 229 | 229 | $output .= "<img src='https://maps.googleapis.com/maps/api/staticmap?center=".esc_attr($args['location'])."&maptype=".esc_attr($args['maptype'])."&zoom=".esc_attr($args['zoom'])."&size=".esc_attr($args['static_width'])."x".esc_attr($args['static_height'])."&key=".esc_attr($args['api_key'])."' />"; |
| 230 | - }else{ |
|
| 230 | + } else{ |
|
| 231 | 231 | $output .= "<iframe width='".esc_attr($args['width'])."' height='".esc_attr($args['height'])."' frameborder='0' allowfullscreen style='border:0;' src='https://www.google.com/maps/embed/v1/".esc_attr($args['type'])."?q=".esc_attr($args['location'])."&maptype=".esc_attr($args['maptype'])."&zoom=".esc_attr($args['zoom'])."&key=".esc_attr($args['api_key'])."' ></iframe> "; |
| 232 | 232 | } |
| 233 | 233 | |
@@ -1,12 +1,12 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if (!defined('ABSPATH')) |
|
| 4 | 4 | die('-1'); |
| 5 | 5 | |
| 6 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
| 6 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
| 7 | 7 | |
| 8 | -if ( ! empty( $message_body ) ) { |
|
| 9 | - echo wpautop( wptexturize( $message_body ) ); |
|
| 8 | +if (!empty($message_body)) { |
|
| 9 | + echo wpautop(wptexturize($message_body)); |
|
| 10 | 10 | } |
| 11 | 11 | |
| 12 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
| 13 | 12 | \ No newline at end of file |
| 13 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |
|
| 14 | 14 | \ No newline at end of file |
@@ -1,7 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if ( !defined('ABSPATH') ) { |
|
| 4 | 4 | die('-1'); |
| 5 | +} |
|
| 5 | 6 | |
| 6 | 7 | do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
| 7 | 8 | |
@@ -1490,8 +1490,8 @@ discard block |
||
| 1490 | 1490 | $table = $wpdb->prefix . 'wpinv_subscriptions'; |
| 1491 | 1491 | |
| 1492 | 1492 | // Fetch invoices. |
| 1493 | - $subscriptions = $wpdb->get_results( |
|
| 1494 | - "SELECT parent_payment_id, product_id, expiration FROM $table |
|
| 1493 | + $subscriptions = $wpdb->get_results( |
|
| 1494 | + "SELECT parent_payment_id, product_id, expiration FROM $table |
|
| 1495 | 1495 | WHERE |
| 1496 | 1496 | $where |
| 1497 | 1497 | AND status IN ( 'trialling', 'active' )"); |
@@ -1556,8 +1556,8 @@ discard block |
||
| 1556 | 1556 | $table = $wpdb->prefix . 'getpaid_invoices'; |
| 1557 | 1557 | |
| 1558 | 1558 | // Fetch invoices. |
| 1559 | - $invoices = $wpdb->get_col( |
|
| 1560 | - "SELECT posts.ID FROM $wpdb->posts as posts |
|
| 1559 | + $invoices = $wpdb->get_col( |
|
| 1560 | + "SELECT posts.ID FROM $wpdb->posts as posts |
|
| 1561 | 1561 | LEFT JOIN $table as invoices ON invoices.post_id = posts.ID |
| 1562 | 1562 | WHERE |
| 1563 | 1563 | $where |
@@ -7,12 +7,12 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // MUST have WordPress. |
| 10 | -if ( !defined( 'WPINC' ) ) { |
|
| 11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 10 | +if (!defined('WPINC')) { |
|
| 11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | function wpinv_init_transactional_emails() { |
| 15 | - $email_actions = apply_filters( 'wpinv_email_actions', array( |
|
| 15 | + $email_actions = apply_filters('wpinv_email_actions', array( |
|
| 16 | 16 | 'wpinv_status_wpi-pending_to_wpi-processing', |
| 17 | 17 | 'wpinv_status_wpi-pending_to_publish', |
| 18 | 18 | 'wpinv_status_wpi-pending_to_wpi-cancelled', |
@@ -30,381 +30,381 @@ discard block |
||
| 30 | 30 | 'wpinv_fully_refunded', |
| 31 | 31 | 'wpinv_partially_refunded', |
| 32 | 32 | 'wpinv_new_invoice_note' |
| 33 | - ) ); |
|
| 33 | + )); |
|
| 34 | 34 | |
| 35 | - foreach ( $email_actions as $action ) { |
|
| 36 | - add_action( $action, 'wpinv_send_transactional_email', 10, 10 ); |
|
| 35 | + foreach ($email_actions as $action) { |
|
| 36 | + add_action($action, 'wpinv_send_transactional_email', 10, 10); |
|
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | -add_action( 'init', 'wpinv_init_transactional_emails' ); |
|
| 39 | +add_action('init', 'wpinv_init_transactional_emails'); |
|
| 40 | 40 | |
| 41 | 41 | // New invoice email |
| 42 | -add_action( 'wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_new_invoice_notification' ); |
|
| 43 | -add_action( 'wpinv_status_wpi-pending_to_publish_notification', 'wpinv_new_invoice_notification' ); |
|
| 44 | -add_action( 'wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_new_invoice_notification' ); |
|
| 45 | -add_action( 'wpinv_status_wpi-failed_to_wpi-processing_notification', 'wpinv_new_invoice_notification' ); |
|
| 46 | -add_action( 'wpinv_status_wpi-failed_to_publish_notification', 'wpinv_new_invoice_notification' ); |
|
| 47 | -add_action( 'wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_new_invoice_notification' ); |
|
| 42 | +add_action('wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_new_invoice_notification'); |
|
| 43 | +add_action('wpinv_status_wpi-pending_to_publish_notification', 'wpinv_new_invoice_notification'); |
|
| 44 | +add_action('wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_new_invoice_notification'); |
|
| 45 | +add_action('wpinv_status_wpi-failed_to_wpi-processing_notification', 'wpinv_new_invoice_notification'); |
|
| 46 | +add_action('wpinv_status_wpi-failed_to_publish_notification', 'wpinv_new_invoice_notification'); |
|
| 47 | +add_action('wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_new_invoice_notification'); |
|
| 48 | 48 | |
| 49 | 49 | // Cancelled invoice email |
| 50 | -add_action( 'wpinv_status_wpi-pending_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification' ); |
|
| 51 | -add_action( 'wpinv_status_wpi-onhold_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification' ); |
|
| 50 | +add_action('wpinv_status_wpi-pending_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification'); |
|
| 51 | +add_action('wpinv_status_wpi-onhold_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification'); |
|
| 52 | 52 | |
| 53 | 53 | // Failed invoice email |
| 54 | -add_action( 'wpinv_status_wpi-pending_to_wpi-failed_notification', 'wpinv_failed_invoice_notification' ); |
|
| 55 | -add_action( 'wpinv_status_wpi-onhold_to_wpi-failed_notification', 'wpinv_failed_invoice_notification' ); |
|
| 54 | +add_action('wpinv_status_wpi-pending_to_wpi-failed_notification', 'wpinv_failed_invoice_notification'); |
|
| 55 | +add_action('wpinv_status_wpi-onhold_to_wpi-failed_notification', 'wpinv_failed_invoice_notification'); |
|
| 56 | 56 | |
| 57 | 57 | // On hold invoice email |
| 58 | -add_action( 'wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification' ); |
|
| 59 | -add_action( 'wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification' ); |
|
| 58 | +add_action('wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification'); |
|
| 59 | +add_action('wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification'); |
|
| 60 | 60 | |
| 61 | 61 | // Processing invoice email |
| 62 | -add_action( 'wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_processing_invoice_notification' ); |
|
| 62 | +add_action('wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_processing_invoice_notification'); |
|
| 63 | 63 | |
| 64 | 64 | // Paid invoice email |
| 65 | -add_action( 'wpinv_status_publish_notification', 'wpinv_completed_invoice_notification' ); |
|
| 65 | +add_action('wpinv_status_publish_notification', 'wpinv_completed_invoice_notification'); |
|
| 66 | 66 | |
| 67 | 67 | // Refunded invoice email |
| 68 | -add_action( 'wpinv_fully_refunded_notification', 'wpinv_fully_refunded_notification' ); |
|
| 69 | -add_action( 'wpinv_partially_refunded_notification', 'wpinv_partially_refunded_notification' ); |
|
| 70 | -add_action( 'wpinv_status_publish_to_wpi-refunded_notification', 'wpinv_fully_refunded_notification' ); |
|
| 71 | -add_action( 'wpinv_status_wpi-processing_to_wpi-refunded_notification', 'wpinv_fully_refunded_notification' ); |
|
| 68 | +add_action('wpinv_fully_refunded_notification', 'wpinv_fully_refunded_notification'); |
|
| 69 | +add_action('wpinv_partially_refunded_notification', 'wpinv_partially_refunded_notification'); |
|
| 70 | +add_action('wpinv_status_publish_to_wpi-refunded_notification', 'wpinv_fully_refunded_notification'); |
|
| 71 | +add_action('wpinv_status_wpi-processing_to_wpi-refunded_notification', 'wpinv_fully_refunded_notification'); |
|
| 72 | 72 | |
| 73 | 73 | // Invoice note |
| 74 | -add_action( 'wpinv_new_invoice_note_notification', 'wpinv_new_invoice_note_notification' ); |
|
| 74 | +add_action('wpinv_new_invoice_note_notification', 'wpinv_new_invoice_note_notification'); |
|
| 75 | 75 | |
| 76 | -add_action( 'wpinv_email_header', 'wpinv_email_header' ); |
|
| 77 | -add_action( 'wpinv_email_footer', 'wpinv_email_footer' ); |
|
| 78 | -add_action( 'wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3 ); |
|
| 79 | -add_action( 'wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3 ); |
|
| 80 | -add_action( 'wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3 ); |
|
| 76 | +add_action('wpinv_email_header', 'wpinv_email_header'); |
|
| 77 | +add_action('wpinv_email_footer', 'wpinv_email_footer'); |
|
| 78 | +add_action('wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3); |
|
| 79 | +add_action('wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3); |
|
| 80 | +add_action('wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3); |
|
| 81 | 81 | |
| 82 | 82 | function wpinv_send_transactional_email() { |
| 83 | 83 | $args = func_get_args(); |
| 84 | 84 | $function = current_filter() . '_notification'; |
| 85 | - do_action_ref_array( $function, $args ); |
|
| 85 | + do_action_ref_array($function, $args); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | -function wpinv_new_invoice_notification( $invoice_id, $new_status = '' ) { |
|
| 88 | +function wpinv_new_invoice_notification($invoice_id, $new_status = '') { |
|
| 89 | 89 | $email_type = 'new_invoice'; |
| 90 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
| 90 | + if (!wpinv_email_is_enabled($email_type)) { |
|
| 91 | 91 | return false; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 95 | - if ( empty( $invoice ) ) { |
|
| 94 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 95 | + if (empty($invoice)) { |
|
| 96 | 96 | return false; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
| 99 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
| 100 | 100 | return false; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
| 104 | - if ( !is_email( $recipient ) ) { |
|
| 103 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
| 104 | + if (!is_email($recipient)) { |
|
| 105 | 105 | return false; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type, true ); |
|
| 108 | + do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type, true); |
|
| 109 | 109 | |
| 110 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
| 111 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
| 112 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
| 113 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
| 114 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
| 110 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
| 111 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
| 112 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
| 113 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
| 114 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
| 115 | 115 | |
| 116 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
| 116 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
| 117 | 117 | 'invoice' => $invoice, |
| 118 | 118 | 'email_type' => $email_type, |
| 119 | 119 | 'email_heading' => $email_heading, |
| 120 | 120 | 'sent_to_admin' => true, |
| 121 | 121 | 'plain_text' => false, |
| 122 | 122 | 'message_body' => $message_body, |
| 123 | - ) ); |
|
| 123 | + )); |
|
| 124 | 124 | |
| 125 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 125 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 126 | 126 | |
| 127 | - do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type, true ); |
|
| 127 | + do_action('wpinv_post_send_invoice_notification', $invoice, $email_type, true); |
|
| 128 | 128 | |
| 129 | 129 | return $sent; |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | -function wpinv_cancelled_invoice_notification( $invoice_id, $new_status = '' ) { |
|
| 132 | +function wpinv_cancelled_invoice_notification($invoice_id, $new_status = '') { |
|
| 133 | 133 | $email_type = 'cancelled_invoice'; |
| 134 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
| 134 | + if (!wpinv_email_is_enabled($email_type)) { |
|
| 135 | 135 | return false; |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 139 | - if ( empty( $invoice ) ) { |
|
| 138 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 139 | + if (empty($invoice)) { |
|
| 140 | 140 | return false; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
| 143 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
| 144 | 144 | return false; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
| 148 | - if ( !is_email( $recipient ) ) { |
|
| 147 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
| 148 | + if (!is_email($recipient)) { |
|
| 149 | 149 | return false; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type, true ); |
|
| 152 | + do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type, true); |
|
| 153 | 153 | |
| 154 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
| 155 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
| 156 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
| 157 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
| 158 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
| 154 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
| 155 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
| 156 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
| 157 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
| 158 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
| 159 | 159 | |
| 160 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
| 160 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
| 161 | 161 | 'invoice' => $invoice, |
| 162 | 162 | 'email_type' => $email_type, |
| 163 | 163 | 'email_heading' => $email_heading, |
| 164 | 164 | 'sent_to_admin' => true, |
| 165 | 165 | 'plain_text' => false, |
| 166 | 166 | 'message_body' => $message_body, |
| 167 | - ) ); |
|
| 167 | + )); |
|
| 168 | 168 | |
| 169 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 169 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 170 | 170 | |
| 171 | - do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type, true ); |
|
| 171 | + do_action('wpinv_post_send_invoice_notification', $invoice, $email_type, true); |
|
| 172 | 172 | |
| 173 | 173 | return $sent; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | -function wpinv_failed_invoice_notification( $invoice_id, $new_status = '' ) { |
|
| 176 | +function wpinv_failed_invoice_notification($invoice_id, $new_status = '') { |
|
| 177 | 177 | $email_type = 'failed_invoice'; |
| 178 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
| 178 | + if (!wpinv_email_is_enabled($email_type)) { |
|
| 179 | 179 | return false; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 183 | - if ( empty( $invoice ) ) { |
|
| 182 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 183 | + if (empty($invoice)) { |
|
| 184 | 184 | return false; |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
| 187 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
| 188 | 188 | return false; |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
| 192 | - if ( !is_email( $recipient ) ) { |
|
| 191 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
| 192 | + if (!is_email($recipient)) { |
|
| 193 | 193 | return false; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type, true ); |
|
| 196 | + do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type, true); |
|
| 197 | 197 | |
| 198 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
| 199 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
| 200 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
| 201 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
| 202 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
| 198 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
| 199 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
| 200 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
| 201 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
| 202 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
| 203 | 203 | |
| 204 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
| 204 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
| 205 | 205 | 'invoice' => $invoice, |
| 206 | 206 | 'email_type' => $email_type, |
| 207 | 207 | 'email_heading' => $email_heading, |
| 208 | 208 | 'sent_to_admin' => true, |
| 209 | 209 | 'plain_text' => false, |
| 210 | 210 | 'message_body' => $message_body, |
| 211 | - ) ); |
|
| 211 | + )); |
|
| 212 | 212 | |
| 213 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 213 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 214 | 214 | |
| 215 | - do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type, true ); |
|
| 215 | + do_action('wpinv_post_send_invoice_notification', $invoice, $email_type, true); |
|
| 216 | 216 | |
| 217 | 217 | return $sent; |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | -function wpinv_onhold_invoice_notification( $invoice_id, $new_status = '' ) { |
|
| 220 | +function wpinv_onhold_invoice_notification($invoice_id, $new_status = '') { |
|
| 221 | 221 | $email_type = 'onhold_invoice'; |
| 222 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
| 222 | + if (!wpinv_email_is_enabled($email_type)) { |
|
| 223 | 223 | return false; |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 227 | - if ( empty( $invoice ) ) { |
|
| 226 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 227 | + if (empty($invoice)) { |
|
| 228 | 228 | return false; |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
| 231 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
| 232 | 232 | return false; |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
| 236 | - if ( !is_email( $recipient ) ) { |
|
| 235 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
| 236 | + if (!is_email($recipient)) { |
|
| 237 | 237 | return false; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type ); |
|
| 240 | + do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type); |
|
| 241 | 241 | |
| 242 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
| 243 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
| 244 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
| 245 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
| 246 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
| 242 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
| 243 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
| 244 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
| 245 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
| 246 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
| 247 | 247 | |
| 248 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
| 248 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
| 249 | 249 | 'invoice' => $invoice, |
| 250 | 250 | 'email_type' => $email_type, |
| 251 | 251 | 'email_heading' => $email_heading, |
| 252 | 252 | 'sent_to_admin' => false, |
| 253 | 253 | 'plain_text' => false, |
| 254 | 254 | 'message_body' => $message_body, |
| 255 | - ) ); |
|
| 255 | + )); |
|
| 256 | 256 | |
| 257 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 257 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 258 | 258 | |
| 259 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
| 260 | - $recipient = wpinv_get_admin_email(); |
|
| 261 | - $subject .= ' - ADMIN BCC COPY'; |
|
| 262 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 259 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
| 260 | + $recipient = wpinv_get_admin_email(); |
|
| 261 | + $subject .= ' - ADMIN BCC COPY'; |
|
| 262 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | - do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type ); |
|
| 265 | + do_action('wpinv_post_send_invoice_notification', $invoice, $email_type); |
|
| 266 | 266 | |
| 267 | 267 | return $sent; |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | -function wpinv_processing_invoice_notification( $invoice_id, $new_status = '' ) { |
|
| 270 | +function wpinv_processing_invoice_notification($invoice_id, $new_status = '') { |
|
| 271 | 271 | $email_type = 'processing_invoice'; |
| 272 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
| 272 | + if (!wpinv_email_is_enabled($email_type)) { |
|
| 273 | 273 | return false; |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 277 | - if ( empty( $invoice ) ) { |
|
| 276 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 277 | + if (empty($invoice)) { |
|
| 278 | 278 | return false; |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
| 281 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
| 282 | 282 | return false; |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
| 286 | - if ( !is_email( $recipient ) ) { |
|
| 285 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
| 286 | + if (!is_email($recipient)) { |
|
| 287 | 287 | return false; |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | - do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type ); |
|
| 290 | + do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type); |
|
| 291 | 291 | |
| 292 | 292 | $search = array(); |
| 293 | 293 | $search['invoice_number'] = '{invoice_number}'; |
| 294 | 294 | $search['invoice_date'] = '{invoice_date}'; |
| 295 | 295 | $search['name'] = '{name}'; |
| 296 | 296 | |
| 297 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
| 298 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
| 299 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
| 300 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
| 301 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
| 297 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
| 298 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
| 299 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
| 300 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
| 301 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
| 302 | 302 | |
| 303 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
| 303 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
| 304 | 304 | 'invoice' => $invoice, |
| 305 | 305 | 'email_type' => $email_type, |
| 306 | 306 | 'email_heading' => $email_heading, |
| 307 | 307 | 'sent_to_admin' => false, |
| 308 | 308 | 'plain_text' => false, |
| 309 | 309 | 'message_body' => $message_body, |
| 310 | - ) ); |
|
| 310 | + )); |
|
| 311 | 311 | |
| 312 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 312 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 313 | 313 | |
| 314 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
| 315 | - $recipient = wpinv_get_admin_email(); |
|
| 316 | - $subject .= ' - ADMIN BCC COPY'; |
|
| 317 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 314 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
| 315 | + $recipient = wpinv_get_admin_email(); |
|
| 316 | + $subject .= ' - ADMIN BCC COPY'; |
|
| 317 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | - do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type ); |
|
| 320 | + do_action('wpinv_post_send_invoice_notification', $invoice, $email_type); |
|
| 321 | 321 | |
| 322 | 322 | return $sent; |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | -function wpinv_completed_invoice_notification( $invoice_id, $new_status = '' ) { |
|
| 325 | +function wpinv_completed_invoice_notification($invoice_id, $new_status = '') { |
|
| 326 | 326 | $email_type = 'completed_invoice'; |
| 327 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
| 327 | + if (!wpinv_email_is_enabled($email_type)) { |
|
| 328 | 328 | return false; |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 332 | - if ( empty( $invoice ) ) { |
|
| 331 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 332 | + if (empty($invoice)) { |
|
| 333 | 333 | return false; |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
| 336 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
| 337 | 337 | return false; |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | - if($invoice->is_renewal() && wpinv_email_is_enabled( 'completed_invoice_renewal' )){ |
|
| 340 | + if ($invoice->is_renewal() && wpinv_email_is_enabled('completed_invoice_renewal')) { |
|
| 341 | 341 | return false; |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
| 345 | - if ( !is_email( $recipient ) ) { |
|
| 344 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
| 345 | + if (!is_email($recipient)) { |
|
| 346 | 346 | return false; |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | - do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type ); |
|
| 349 | + do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type); |
|
| 350 | 350 | |
| 351 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
| 352 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
| 353 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
| 354 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
| 355 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
| 351 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
| 352 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
| 353 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
| 354 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
| 355 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
| 356 | 356 | |
| 357 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
| 357 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
| 358 | 358 | 'invoice' => $invoice, |
| 359 | 359 | 'email_type' => $email_type, |
| 360 | 360 | 'email_heading' => $email_heading, |
| 361 | 361 | 'sent_to_admin' => false, |
| 362 | 362 | 'plain_text' => false, |
| 363 | 363 | 'message_body' => $message_body, |
| 364 | - ) ); |
|
| 364 | + )); |
|
| 365 | 365 | |
| 366 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 366 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 367 | 367 | |
| 368 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
| 369 | - $recipient = wpinv_get_admin_email(); |
|
| 370 | - $subject .= ' - ADMIN BCC COPY'; |
|
| 371 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 368 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
| 369 | + $recipient = wpinv_get_admin_email(); |
|
| 370 | + $subject .= ' - ADMIN BCC COPY'; |
|
| 371 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 372 | 372 | } |
| 373 | 373 | |
| 374 | - do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type ); |
|
| 374 | + do_action('wpinv_post_send_invoice_notification', $invoice, $email_type); |
|
| 375 | 375 | |
| 376 | 376 | return $sent; |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | -function wpinv_fully_refunded_notification( $invoice_id, $new_status = '' ) { |
|
| 379 | +function wpinv_fully_refunded_notification($invoice_id, $new_status = '') { |
|
| 380 | 380 | $email_type = 'refunded_invoice'; |
| 381 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
| 381 | + if (!wpinv_email_is_enabled($email_type)) { |
|
| 382 | 382 | return false; |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 386 | - if ( empty( $invoice ) ) { |
|
| 385 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 386 | + if (empty($invoice)) { |
|
| 387 | 387 | return false; |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
| 390 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
| 391 | 391 | return false; |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
| 395 | - if ( !is_email( $recipient ) ) { |
|
| 394 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
| 395 | + if (!is_email($recipient)) { |
|
| 396 | 396 | return false; |
| 397 | 397 | } |
| 398 | 398 | |
| 399 | - do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type ); |
|
| 399 | + do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type); |
|
| 400 | 400 | |
| 401 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
| 402 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
| 403 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
| 404 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
| 405 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
| 401 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
| 402 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
| 403 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
| 404 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
| 405 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
| 406 | 406 | |
| 407 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
| 407 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
| 408 | 408 | 'invoice' => $invoice, |
| 409 | 409 | 'email_type' => $email_type, |
| 410 | 410 | 'email_heading' => $email_heading, |
@@ -412,50 +412,50 @@ discard block |
||
| 412 | 412 | 'plain_text' => false, |
| 413 | 413 | 'partial_refund' => false, |
| 414 | 414 | 'message_body' => $message_body, |
| 415 | - ) ); |
|
| 415 | + )); |
|
| 416 | 416 | |
| 417 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 417 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 418 | 418 | |
| 419 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
| 420 | - $recipient = wpinv_get_admin_email(); |
|
| 421 | - $subject .= ' - ADMIN BCC COPY'; |
|
| 422 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 419 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
| 420 | + $recipient = wpinv_get_admin_email(); |
|
| 421 | + $subject .= ' - ADMIN BCC COPY'; |
|
| 422 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | - do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type ); |
|
| 425 | + do_action('wpinv_post_send_invoice_notification', $invoice, $email_type); |
|
| 426 | 426 | |
| 427 | 427 | return $sent; |
| 428 | 428 | } |
| 429 | 429 | |
| 430 | -function wpinv_partially_refunded_notification( $invoice_id, $new_status = '' ) { |
|
| 430 | +function wpinv_partially_refunded_notification($invoice_id, $new_status = '') { |
|
| 431 | 431 | $email_type = 'refunded_invoice'; |
| 432 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
| 432 | + if (!wpinv_email_is_enabled($email_type)) { |
|
| 433 | 433 | return false; |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 437 | - if ( empty( $invoice ) ) { |
|
| 436 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 437 | + if (empty($invoice)) { |
|
| 438 | 438 | return false; |
| 439 | 439 | } |
| 440 | 440 | |
| 441 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
| 441 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
| 442 | 442 | return false; |
| 443 | 443 | } |
| 444 | 444 | |
| 445 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
| 446 | - if ( !is_email( $recipient ) ) { |
|
| 445 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
| 446 | + if (!is_email($recipient)) { |
|
| 447 | 447 | return false; |
| 448 | 448 | } |
| 449 | 449 | |
| 450 | - do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type ); |
|
| 450 | + do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type); |
|
| 451 | 451 | |
| 452 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
| 453 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
| 454 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
| 455 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
| 456 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
| 452 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
| 453 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
| 454 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
| 455 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
| 456 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
| 457 | 457 | |
| 458 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
| 458 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
| 459 | 459 | 'invoice' => $invoice, |
| 460 | 460 | 'email_type' => $email_type, |
| 461 | 461 | 'email_heading' => $email_heading, |
@@ -463,95 +463,95 @@ discard block |
||
| 463 | 463 | 'plain_text' => false, |
| 464 | 464 | 'partial_refund' => true, |
| 465 | 465 | 'message_body' => $message_body, |
| 466 | - ) ); |
|
| 466 | + )); |
|
| 467 | 467 | |
| 468 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 468 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 469 | 469 | |
| 470 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
| 471 | - $recipient = wpinv_get_admin_email(); |
|
| 472 | - $subject .= ' - ADMIN BCC COPY'; |
|
| 473 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 470 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
| 471 | + $recipient = wpinv_get_admin_email(); |
|
| 472 | + $subject .= ' - ADMIN BCC COPY'; |
|
| 473 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 474 | 474 | } |
| 475 | 475 | |
| 476 | - do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type ); |
|
| 476 | + do_action('wpinv_post_send_invoice_notification', $invoice, $email_type); |
|
| 477 | 477 | |
| 478 | 478 | return $sent; |
| 479 | 479 | } |
| 480 | 480 | |
| 481 | -function wpinv_new_invoice_note_notification( $invoice_id, $new_status = '' ) { |
|
| 481 | +function wpinv_new_invoice_note_notification($invoice_id, $new_status = '') { |
|
| 482 | 482 | } |
| 483 | 483 | |
| 484 | -function wpinv_user_invoice_notification( $invoice_id ) { |
|
| 484 | +function wpinv_user_invoice_notification($invoice_id) { |
|
| 485 | 485 | $email_type = 'user_invoice'; |
| 486 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
| 486 | + if (!wpinv_email_is_enabled($email_type)) { |
|
| 487 | 487 | return -1; |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 491 | - if ( empty( $invoice ) ) { |
|
| 490 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 491 | + if (empty($invoice)) { |
|
| 492 | 492 | return false; |
| 493 | 493 | } |
| 494 | 494 | |
| 495 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
| 495 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
| 496 | 496 | return false; |
| 497 | 497 | } |
| 498 | 498 | |
| 499 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
| 500 | - if ( !is_email( $recipient ) ) { |
|
| 499 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
| 500 | + if (!is_email($recipient)) { |
|
| 501 | 501 | return false; |
| 502 | 502 | } |
| 503 | 503 | |
| 504 | - do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type ); |
|
| 504 | + do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type); |
|
| 505 | 505 | |
| 506 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
| 507 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
| 508 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
| 509 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
| 510 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
| 506 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
| 507 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
| 508 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
| 509 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
| 510 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
| 511 | 511 | |
| 512 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
| 512 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
| 513 | 513 | 'invoice' => $invoice, |
| 514 | 514 | 'email_type' => $email_type, |
| 515 | 515 | 'email_heading' => $email_heading, |
| 516 | 516 | 'sent_to_admin' => false, |
| 517 | 517 | 'plain_text' => false, |
| 518 | 518 | 'message_body' => $message_body, |
| 519 | - ) ); |
|
| 519 | + )); |
|
| 520 | 520 | |
| 521 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 521 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 522 | 522 | |
| 523 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
| 524 | - $recipient = wpinv_get_admin_email(); |
|
| 525 | - $subject .= ' - ADMIN BCC COPY'; |
|
| 526 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 523 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
| 524 | + $recipient = wpinv_get_admin_email(); |
|
| 525 | + $subject .= ' - ADMIN BCC COPY'; |
|
| 526 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 527 | 527 | } |
| 528 | 528 | |
| 529 | - do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type ); |
|
| 529 | + do_action('wpinv_post_send_invoice_notification', $invoice, $email_type); |
|
| 530 | 530 | |
| 531 | - if ( $sent ) { |
|
| 532 | - $note = __( 'Invoice has been emailed to the user.', 'invoicing' ); |
|
| 531 | + if ($sent) { |
|
| 532 | + $note = __('Invoice has been emailed to the user.', 'invoicing'); |
|
| 533 | 533 | } else { |
| 534 | - $note = __( 'Fail to send invoice to the user!', 'invoicing' ); |
|
| 534 | + $note = __('Fail to send invoice to the user!', 'invoicing'); |
|
| 535 | 535 | } |
| 536 | 536 | |
| 537 | - $invoice->add_note( $note, '', '', true ); // Add system note. |
|
| 537 | + $invoice->add_note($note, '', '', true); // Add system note. |
|
| 538 | 538 | |
| 539 | 539 | return $sent; |
| 540 | 540 | } |
| 541 | 541 | |
| 542 | -function wpinv_user_note_notification( $invoice_id, $args = array() ) { |
|
| 542 | +function wpinv_user_note_notification($invoice_id, $args = array()) { |
|
| 543 | 543 | $email_type = 'user_note'; |
| 544 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
| 544 | + if (!wpinv_email_is_enabled($email_type)) { |
|
| 545 | 545 | return false; |
| 546 | 546 | } |
| 547 | 547 | |
| 548 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 549 | - if ( empty( $invoice ) ) { |
|
| 548 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 549 | + if (empty($invoice)) { |
|
| 550 | 550 | return false; |
| 551 | 551 | } |
| 552 | 552 | |
| 553 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
| 554 | - if ( !is_email( $recipient ) ) { |
|
| 553 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
| 554 | + if (!is_email($recipient)) { |
|
| 555 | 555 | return false; |
| 556 | 556 | } |
| 557 | 557 | |
@@ -559,19 +559,19 @@ discard block |
||
| 559 | 559 | 'user_note' => '' |
| 560 | 560 | ); |
| 561 | 561 | |
| 562 | - $args = wp_parse_args( $args, $defaults ); |
|
| 562 | + $args = wp_parse_args($args, $defaults); |
|
| 563 | 563 | |
| 564 | - do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type ); |
|
| 564 | + do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type); |
|
| 565 | 565 | |
| 566 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
| 567 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
| 568 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
| 569 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
| 570 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
| 566 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
| 567 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
| 568 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
| 569 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
| 570 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
| 571 | 571 | |
| 572 | - $message_body = str_replace( '{customer_note}', $args['user_note'], $message_body ); |
|
| 572 | + $message_body = str_replace('{customer_note}', $args['user_note'], $message_body); |
|
| 573 | 573 | |
| 574 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
| 574 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
| 575 | 575 | 'invoice' => $invoice, |
| 576 | 576 | 'email_type' => $email_type, |
| 577 | 577 | 'email_heading' => $email_heading, |
@@ -579,36 +579,36 @@ discard block |
||
| 579 | 579 | 'plain_text' => false, |
| 580 | 580 | 'message_body' => $message_body, |
| 581 | 581 | 'customer_note' => $args['user_note'] |
| 582 | - ) ); |
|
| 582 | + )); |
|
| 583 | 583 | |
| 584 | - $content = wpinv_email_format_text( $content, $invoice ); |
|
| 584 | + $content = wpinv_email_format_text($content, $invoice); |
|
| 585 | 585 | |
| 586 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 586 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 587 | 587 | |
| 588 | - do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type ); |
|
| 588 | + do_action('wpinv_post_send_invoice_notification', $invoice, $email_type); |
|
| 589 | 589 | |
| 590 | 590 | return $sent; |
| 591 | 591 | } |
| 592 | 592 | |
| 593 | 593 | function wpinv_mail_get_from_address() { |
| 594 | - $from_address = apply_filters( 'wpinv_mail_from_address', wpinv_get_option( 'email_from' ) ); |
|
| 595 | - return sanitize_email( $from_address ); |
|
| 594 | + $from_address = apply_filters('wpinv_mail_from_address', wpinv_get_option('email_from')); |
|
| 595 | + return sanitize_email($from_address); |
|
| 596 | 596 | } |
| 597 | 597 | |
| 598 | 598 | function wpinv_mail_get_from_name() { |
| 599 | - $from_name = apply_filters( 'wpinv_mail_from_name', wpinv_get_option( 'email_from_name' ) ); |
|
| 600 | - return wp_specialchars_decode( esc_html( $from_name ), ENT_QUOTES ); |
|
| 599 | + $from_name = apply_filters('wpinv_mail_from_name', wpinv_get_option('email_from_name')); |
|
| 600 | + return wp_specialchars_decode(esc_html($from_name), ENT_QUOTES); |
|
| 601 | 601 | } |
| 602 | 602 | |
| 603 | -function wpinv_mail_admin_bcc_active( $mail_type = '' ) { |
|
| 604 | - $active = apply_filters( 'wpinv_mail_admin_bcc_active', wpinv_get_option( 'email_' . $mail_type . '_admin_bcc' ) ); |
|
| 605 | - return ( $active ? true : false ); |
|
| 603 | +function wpinv_mail_admin_bcc_active($mail_type = '') { |
|
| 604 | + $active = apply_filters('wpinv_mail_admin_bcc_active', wpinv_get_option('email_' . $mail_type . '_admin_bcc')); |
|
| 605 | + return ($active ? true : false); |
|
| 606 | 606 | } |
| 607 | 607 | |
| 608 | -function wpinv_mail_get_content_type( $content_type = 'text/html', $email_type = 'html' ) { |
|
| 609 | - $email_type = apply_filters( 'wpinv_mail_content_type', $email_type ); |
|
| 608 | +function wpinv_mail_get_content_type($content_type = 'text/html', $email_type = 'html') { |
|
| 609 | + $email_type = apply_filters('wpinv_mail_content_type', $email_type); |
|
| 610 | 610 | |
| 611 | - switch ( $email_type ) { |
|
| 611 | + switch ($email_type) { |
|
| 612 | 612 | case 'html' : |
| 613 | 613 | $content_type = 'text/html'; |
| 614 | 614 | break; |
@@ -623,35 +623,35 @@ discard block |
||
| 623 | 623 | return $content_type; |
| 624 | 624 | } |
| 625 | 625 | |
| 626 | -function wpinv_mail_send( $to, $subject, $message, $headers, $attachments ) { |
|
| 627 | - add_filter( 'wp_mail_from', 'wpinv_mail_get_from_address' ); |
|
| 628 | - add_filter( 'wp_mail_from_name', 'wpinv_mail_get_from_name' ); |
|
| 629 | - add_filter( 'wp_mail_content_type', 'wpinv_mail_get_content_type' ); |
|
| 626 | +function wpinv_mail_send($to, $subject, $message, $headers, $attachments) { |
|
| 627 | + add_filter('wp_mail_from', 'wpinv_mail_get_from_address'); |
|
| 628 | + add_filter('wp_mail_from_name', 'wpinv_mail_get_from_name'); |
|
| 629 | + add_filter('wp_mail_content_type', 'wpinv_mail_get_content_type'); |
|
| 630 | 630 | |
| 631 | - $message = wpinv_email_style_body( $message ); |
|
| 632 | - $message = apply_filters( 'wpinv_mail_content', $message ); |
|
| 631 | + $message = wpinv_email_style_body($message); |
|
| 632 | + $message = apply_filters('wpinv_mail_content', $message); |
|
| 633 | 633 | |
| 634 | - $sent = wp_mail( $to, $subject, $message, $headers, $attachments ); |
|
| 634 | + $sent = wp_mail($to, $subject, $message, $headers, $attachments); |
|
| 635 | 635 | |
| 636 | - if ( !$sent ) { |
|
| 637 | - $log_message = wp_sprintf( __( "\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing' ), date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), ( is_array( $to ) ? implode( ', ', $to ) : $to ), $subject ); |
|
| 638 | - wpinv_error_log( $log_message, __( "Email from Invoicing plugin failed to send", 'invoicing' ), __FILE__, __LINE__ ); |
|
| 636 | + if (!$sent) { |
|
| 637 | + $log_message = wp_sprintf(__("\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing'), date_i18n('F j Y H:i:s', current_time('timestamp')), (is_array($to) ? implode(', ', $to) : $to), $subject); |
|
| 638 | + wpinv_error_log($log_message, __("Email from Invoicing plugin failed to send", 'invoicing'), __FILE__, __LINE__); |
|
| 639 | 639 | } |
| 640 | 640 | |
| 641 | - remove_filter( 'wp_mail_from', 'wpinv_mail_get_from_address' ); |
|
| 642 | - remove_filter( 'wp_mail_from_name', 'wpinv_mail_get_from_name' ); |
|
| 643 | - remove_filter( 'wp_mail_content_type', 'wpinv_mail_get_content_type' ); |
|
| 641 | + remove_filter('wp_mail_from', 'wpinv_mail_get_from_address'); |
|
| 642 | + remove_filter('wp_mail_from_name', 'wpinv_mail_get_from_name'); |
|
| 643 | + remove_filter('wp_mail_content_type', 'wpinv_mail_get_content_type'); |
|
| 644 | 644 | |
| 645 | 645 | return $sent; |
| 646 | 646 | } |
| 647 | 647 | |
| 648 | 648 | function wpinv_get_emails() { |
| 649 | 649 | $overdue_days_options = array(); |
| 650 | - $overdue_days_options[0] = __( 'On the Due Date', 'invoicing' ); |
|
| 651 | - $overdue_days_options[1] = __( '1 day after Due Date', 'invoicing' ); |
|
| 650 | + $overdue_days_options[0] = __('On the Due Date', 'invoicing'); |
|
| 651 | + $overdue_days_options[1] = __('1 day after Due Date', 'invoicing'); |
|
| 652 | 652 | |
| 653 | - for ( $i = 2; $i <= 10; $i++ ) { |
|
| 654 | - $overdue_days_options[$i] = wp_sprintf( __( '%d days after Due Date', 'invoicing' ), $i ); |
|
| 653 | + for ($i = 2; $i <= 10; $i++) { |
|
| 654 | + $overdue_days_options[$i] = wp_sprintf(__('%d days after Due Date', 'invoicing'), $i); |
|
| 655 | 655 | } |
| 656 | 656 | |
| 657 | 657 | // Default, built-in gateways |
@@ -659,39 +659,39 @@ discard block |
||
| 659 | 659 | 'new_invoice' => array( |
| 660 | 660 | 'email_new_invoice_header' => array( |
| 661 | 661 | 'id' => 'email_new_invoice_header', |
| 662 | - 'name' => '<h3>' . __( 'New Invoice', 'invoicing' ) . '</h3>', |
|
| 663 | - 'desc' => __( 'New invoice emails are sent to admin when a new invoice is received.', 'invoicing' ), |
|
| 662 | + 'name' => '<h3>' . __('New Invoice', 'invoicing') . '</h3>', |
|
| 663 | + 'desc' => __('New invoice emails are sent to admin when a new invoice is received.', 'invoicing'), |
|
| 664 | 664 | 'type' => 'header', |
| 665 | 665 | ), |
| 666 | 666 | 'email_new_invoice_active' => array( |
| 667 | 667 | 'id' => 'email_new_invoice_active', |
| 668 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
| 669 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
| 668 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
| 669 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
| 670 | 670 | 'type' => 'checkbox', |
| 671 | 671 | 'std' => 1 |
| 672 | 672 | ), |
| 673 | 673 | 'email_new_invoice_subject' => array( |
| 674 | 674 | 'id' => 'email_new_invoice_subject', |
| 675 | - 'name' => __( 'Subject', 'invoicing' ), |
|
| 676 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
| 675 | + 'name' => __('Subject', 'invoicing'), |
|
| 676 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
| 677 | 677 | 'type' => 'text', |
| 678 | - 'std' => __( '[{site_title}] New payment invoice ({invoice_number}) - {invoice_date}', 'invoicing' ), |
|
| 678 | + 'std' => __('[{site_title}] New payment invoice ({invoice_number}) - {invoice_date}', 'invoicing'), |
|
| 679 | 679 | 'size' => 'large' |
| 680 | 680 | ), |
| 681 | 681 | 'email_new_invoice_heading' => array( |
| 682 | 682 | 'id' => 'email_new_invoice_heading', |
| 683 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
| 684 | - 'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ), |
|
| 683 | + 'name' => __('Email Heading', 'invoicing'), |
|
| 684 | + 'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'), |
|
| 685 | 685 | 'type' => 'text', |
| 686 | - 'std' => __( 'New payment invoice', 'invoicing' ), |
|
| 686 | + 'std' => __('New payment invoice', 'invoicing'), |
|
| 687 | 687 | 'size' => 'large' |
| 688 | 688 | ), |
| 689 | 689 | 'email_new_invoice_body' => array( |
| 690 | 690 | 'id' => 'email_new_invoice_body', |
| 691 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
| 692 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
| 691 | + 'name' => __('Email Content', 'invoicing'), |
|
| 692 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
| 693 | 693 | 'type' => 'rich_editor', |
| 694 | - 'std' => __( '<p>Hi Admin,</p><p>You have received payment invoice from {name}.</p>', 'invoicing' ), |
|
| 694 | + 'std' => __('<p>Hi Admin,</p><p>You have received payment invoice from {name}.</p>', 'invoicing'), |
|
| 695 | 695 | 'class' => 'large', |
| 696 | 696 | 'size' => '10' |
| 697 | 697 | ), |
@@ -699,39 +699,39 @@ discard block |
||
| 699 | 699 | 'cancelled_invoice' => array( |
| 700 | 700 | 'email_cancelled_invoice_header' => array( |
| 701 | 701 | 'id' => 'email_cancelled_invoice_header', |
| 702 | - 'name' => '<h3>' . __( 'Cancelled Invoice', 'invoicing' ) . '</h3>', |
|
| 703 | - 'desc' => __( 'Cancelled invoice emails are sent to admin when invoices have been marked cancelled.', 'invoicing' ), |
|
| 702 | + 'name' => '<h3>' . __('Cancelled Invoice', 'invoicing') . '</h3>', |
|
| 703 | + 'desc' => __('Cancelled invoice emails are sent to admin when invoices have been marked cancelled.', 'invoicing'), |
|
| 704 | 704 | 'type' => 'header', |
| 705 | 705 | ), |
| 706 | 706 | 'email_cancelled_invoice_active' => array( |
| 707 | 707 | 'id' => 'email_cancelled_invoice_active', |
| 708 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
| 709 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
| 708 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
| 709 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
| 710 | 710 | 'type' => 'checkbox', |
| 711 | 711 | 'std' => 1 |
| 712 | 712 | ), |
| 713 | 713 | 'email_cancelled_invoice_subject' => array( |
| 714 | 714 | 'id' => 'email_cancelled_invoice_subject', |
| 715 | - 'name' => __( 'Subject', 'invoicing' ), |
|
| 716 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
| 715 | + 'name' => __('Subject', 'invoicing'), |
|
| 716 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
| 717 | 717 | 'type' => 'text', |
| 718 | - 'std' => __( '[{site_title}] Cancelled invoice ({invoice_number})', 'invoicing' ), |
|
| 718 | + 'std' => __('[{site_title}] Cancelled invoice ({invoice_number})', 'invoicing'), |
|
| 719 | 719 | 'size' => 'large' |
| 720 | 720 | ), |
| 721 | 721 | 'email_cancelled_invoice_heading' => array( |
| 722 | 722 | 'id' => 'email_cancelled_invoice_heading', |
| 723 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
| 724 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
| 723 | + 'name' => __('Email Heading', 'invoicing'), |
|
| 724 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
| 725 | 725 | 'type' => 'text', |
| 726 | - 'std' => __( 'Cancelled invoice', 'invoicing' ), |
|
| 726 | + 'std' => __('Cancelled invoice', 'invoicing'), |
|
| 727 | 727 | 'size' => 'large' |
| 728 | 728 | ), |
| 729 | 729 | 'email_cancelled_invoice_body' => array( |
| 730 | 730 | 'id' => 'email_cancelled_invoice_body', |
| 731 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
| 732 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
| 731 | + 'name' => __('Email Content', 'invoicing'), |
|
| 732 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
| 733 | 733 | 'type' => 'rich_editor', |
| 734 | - 'std' => __( '<p>Hi Admin,</p><p>The invoice #{invoice_number} from {site_title} has been cancelled.</p>', 'invoicing' ), |
|
| 734 | + 'std' => __('<p>Hi Admin,</p><p>The invoice #{invoice_number} from {site_title} has been cancelled.</p>', 'invoicing'), |
|
| 735 | 735 | 'class' => 'large', |
| 736 | 736 | 'size' => '10' |
| 737 | 737 | ), |
@@ -739,39 +739,39 @@ discard block |
||
| 739 | 739 | 'failed_invoice' => array( |
| 740 | 740 | 'email_failed_invoice_header' => array( |
| 741 | 741 | 'id' => 'email_failed_invoice_header', |
| 742 | - 'name' => '<h3>' . __( 'Failed Invoice', 'invoicing' ) . '</h3>', |
|
| 743 | - 'desc' => __( 'Failed invoice emails are sent to admin when invoices have been marked failed (if they were previously processing or on-hold).', 'invoicing' ), |
|
| 742 | + 'name' => '<h3>' . __('Failed Invoice', 'invoicing') . '</h3>', |
|
| 743 | + 'desc' => __('Failed invoice emails are sent to admin when invoices have been marked failed (if they were previously processing or on-hold).', 'invoicing'), |
|
| 744 | 744 | 'type' => 'header', |
| 745 | 745 | ), |
| 746 | 746 | 'email_failed_invoice_active' => array( |
| 747 | 747 | 'id' => 'email_failed_invoice_active', |
| 748 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
| 749 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
| 748 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
| 749 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
| 750 | 750 | 'type' => 'checkbox', |
| 751 | 751 | 'std' => 1 |
| 752 | 752 | ), |
| 753 | 753 | 'email_failed_invoice_subject' => array( |
| 754 | 754 | 'id' => 'email_failed_invoice_subject', |
| 755 | - 'name' => __( 'Subject', 'invoicing' ), |
|
| 756 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
| 755 | + 'name' => __('Subject', 'invoicing'), |
|
| 756 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
| 757 | 757 | 'type' => 'text', |
| 758 | - 'std' => __( '[{site_title}] Failed invoice ({invoice_number})', 'invoicing' ), |
|
| 758 | + 'std' => __('[{site_title}] Failed invoice ({invoice_number})', 'invoicing'), |
|
| 759 | 759 | 'size' => 'large' |
| 760 | 760 | ), |
| 761 | 761 | 'email_failed_invoice_heading' => array( |
| 762 | 762 | 'id' => 'email_failed_invoice_heading', |
| 763 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
| 764 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
| 763 | + 'name' => __('Email Heading', 'invoicing'), |
|
| 764 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
| 765 | 765 | 'type' => 'text', |
| 766 | - 'std' => __( 'Failed invoice', 'invoicing' ), |
|
| 766 | + 'std' => __('Failed invoice', 'invoicing'), |
|
| 767 | 767 | 'size' => 'large' |
| 768 | 768 | ), |
| 769 | 769 | 'email_failed_invoice_body' => array( |
| 770 | 770 | 'id' => 'email_failed_invoice_body', |
| 771 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
| 772 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
| 771 | + 'name' => __('Email Content', 'invoicing'), |
|
| 772 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
| 773 | 773 | 'type' => 'rich_editor', |
| 774 | - 'std' => __( '<p>Hi Admin,</p><p>Payment for invoice #{invoice_number} from {site_title} has been failed.</p>', 'invoicing' ), |
|
| 774 | + 'std' => __('<p>Hi Admin,</p><p>Payment for invoice #{invoice_number} from {site_title} has been failed.</p>', 'invoicing'), |
|
| 775 | 775 | 'class' => 'large', |
| 776 | 776 | 'size' => '10' |
| 777 | 777 | ), |
@@ -779,46 +779,46 @@ discard block |
||
| 779 | 779 | 'onhold_invoice' => array( |
| 780 | 780 | 'email_onhold_invoice_header' => array( |
| 781 | 781 | 'id' => 'email_onhold_invoice_header', |
| 782 | - 'name' => '<h3>' . __( 'On Hold Invoice', 'invoicing' ) . '</h3>', |
|
| 783 | - 'desc' => __( 'This is an invoice notification sent to users containing invoice details after an invoice is placed on-hold.', 'invoicing' ), |
|
| 782 | + 'name' => '<h3>' . __('On Hold Invoice', 'invoicing') . '</h3>', |
|
| 783 | + 'desc' => __('This is an invoice notification sent to users containing invoice details after an invoice is placed on-hold.', 'invoicing'), |
|
| 784 | 784 | 'type' => 'header', |
| 785 | 785 | ), |
| 786 | 786 | 'email_onhold_invoice_active' => array( |
| 787 | 787 | 'id' => 'email_onhold_invoice_active', |
| 788 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
| 789 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
| 788 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
| 789 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
| 790 | 790 | 'type' => 'checkbox', |
| 791 | 791 | 'std' => 1 |
| 792 | 792 | ), |
| 793 | 793 | 'email_onhold_invoice_subject' => array( |
| 794 | 794 | 'id' => 'email_onhold_invoice_subject', |
| 795 | - 'name' => __( 'Subject', 'invoicing' ), |
|
| 796 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
| 795 | + 'name' => __('Subject', 'invoicing'), |
|
| 796 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
| 797 | 797 | 'type' => 'text', |
| 798 | - 'std' => __( '[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing' ), |
|
| 798 | + 'std' => __('[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing'), |
|
| 799 | 799 | 'size' => 'large' |
| 800 | 800 | ), |
| 801 | 801 | 'email_onhold_invoice_heading' => array( |
| 802 | 802 | 'id' => 'email_onhold_invoice_heading', |
| 803 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
| 804 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
| 803 | + 'name' => __('Email Heading', 'invoicing'), |
|
| 804 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
| 805 | 805 | 'type' => 'text', |
| 806 | - 'std' => __( 'Thank you for your invoice', 'invoicing' ), |
|
| 806 | + 'std' => __('Thank you for your invoice', 'invoicing'), |
|
| 807 | 807 | 'size' => 'large' |
| 808 | 808 | ), |
| 809 | 809 | 'email_onhold_invoice_admin_bcc' => array( |
| 810 | 810 | 'id' => 'email_onhold_invoice_admin_bcc', |
| 811 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
| 812 | - 'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ), |
|
| 811 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
| 812 | + 'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'), |
|
| 813 | 813 | 'type' => 'checkbox', |
| 814 | 814 | 'std' => 1 |
| 815 | 815 | ), |
| 816 | 816 | 'email_onhold_invoice_body' => array( |
| 817 | 817 | 'id' => 'email_onhold_invoice_body', |
| 818 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
| 819 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
| 818 | + 'name' => __('Email Content', 'invoicing'), |
|
| 819 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
| 820 | 820 | 'type' => 'rich_editor', |
| 821 | - 'std' => __( '<p>Hi {name},</p><p>Your invoice is on-hold until we confirm your payment has been received.</p>', 'invoicing' ), |
|
| 821 | + 'std' => __('<p>Hi {name},</p><p>Your invoice is on-hold until we confirm your payment has been received.</p>', 'invoicing'), |
|
| 822 | 822 | 'class' => 'large', |
| 823 | 823 | 'size' => '10' |
| 824 | 824 | ), |
@@ -826,46 +826,46 @@ discard block |
||
| 826 | 826 | 'processing_invoice' => array( |
| 827 | 827 | 'email_processing_invoice_header' => array( |
| 828 | 828 | 'id' => 'email_processing_invoice_header', |
| 829 | - 'name' => '<h3>' . __( 'Processing Invoice', 'invoicing' ) . '</h3>', |
|
| 830 | - 'desc' => __( 'This is an invoice notification sent to users containing invoice details after payment.', 'invoicing' ), |
|
| 829 | + 'name' => '<h3>' . __('Processing Invoice', 'invoicing') . '</h3>', |
|
| 830 | + 'desc' => __('This is an invoice notification sent to users containing invoice details after payment.', 'invoicing'), |
|
| 831 | 831 | 'type' => 'header', |
| 832 | 832 | ), |
| 833 | 833 | 'email_processing_invoice_active' => array( |
| 834 | 834 | 'id' => 'email_processing_invoice_active', |
| 835 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
| 836 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
| 835 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
| 836 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
| 837 | 837 | 'type' => 'checkbox', |
| 838 | 838 | 'std' => 1 |
| 839 | 839 | ), |
| 840 | 840 | 'email_processing_invoice_subject' => array( |
| 841 | 841 | 'id' => 'email_processing_invoice_subject', |
| 842 | - 'name' => __( 'Subject', 'invoicing' ), |
|
| 843 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
| 842 | + 'name' => __('Subject', 'invoicing'), |
|
| 843 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
| 844 | 844 | 'type' => 'text', |
| 845 | - 'std' => __( '[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing' ), |
|
| 845 | + 'std' => __('[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing'), |
|
| 846 | 846 | 'size' => 'large' |
| 847 | 847 | ), |
| 848 | 848 | 'email_processing_invoice_heading' => array( |
| 849 | 849 | 'id' => 'email_processing_invoice_heading', |
| 850 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
| 851 | - 'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ), |
|
| 850 | + 'name' => __('Email Heading', 'invoicing'), |
|
| 851 | + 'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'), |
|
| 852 | 852 | 'type' => 'text', |
| 853 | - 'std' => __( 'Thank you for your invoice', 'invoicing' ), |
|
| 853 | + 'std' => __('Thank you for your invoice', 'invoicing'), |
|
| 854 | 854 | 'size' => 'large' |
| 855 | 855 | ), |
| 856 | 856 | 'email_processing_invoice_admin_bcc' => array( |
| 857 | 857 | 'id' => 'email_processing_invoice_admin_bcc', |
| 858 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
| 859 | - 'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ), |
|
| 858 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
| 859 | + 'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'), |
|
| 860 | 860 | 'type' => 'checkbox', |
| 861 | 861 | 'std' => 1 |
| 862 | 862 | ), |
| 863 | 863 | 'email_processing_invoice_body' => array( |
| 864 | 864 | 'id' => 'email_processing_invoice_body', |
| 865 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
| 866 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
| 865 | + 'name' => __('Email Content', 'invoicing'), |
|
| 866 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
| 867 | 867 | 'type' => 'rich_editor', |
| 868 | - 'std' => __( '<p>Hi {name},</p><p>Your invoice has been received at {site_title} and is now being processed.</p>', 'invoicing' ), |
|
| 868 | + 'std' => __('<p>Hi {name},</p><p>Your invoice has been received at {site_title} and is now being processed.</p>', 'invoicing'), |
|
| 869 | 869 | 'class' => 'large', |
| 870 | 870 | 'size' => '10' |
| 871 | 871 | ), |
@@ -873,52 +873,52 @@ discard block |
||
| 873 | 873 | 'completed_invoice' => array( |
| 874 | 874 | 'email_completed_invoice_header' => array( |
| 875 | 875 | 'id' => 'email_completed_invoice_header', |
| 876 | - 'name' => '<h3>' . __( 'Paid Invoice', 'invoicing' ) . '</h3>', |
|
| 877 | - 'desc' => __( 'Invoice paid emails are sent to users when their invoices are marked paid and usually indicate that their payment has been done.', 'invoicing' ), |
|
| 876 | + 'name' => '<h3>' . __('Paid Invoice', 'invoicing') . '</h3>', |
|
| 877 | + 'desc' => __('Invoice paid emails are sent to users when their invoices are marked paid and usually indicate that their payment has been done.', 'invoicing'), |
|
| 878 | 878 | 'type' => 'header', |
| 879 | 879 | ), |
| 880 | 880 | 'email_completed_invoice_active' => array( |
| 881 | 881 | 'id' => 'email_completed_invoice_active', |
| 882 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
| 883 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
| 882 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
| 883 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
| 884 | 884 | 'type' => 'checkbox', |
| 885 | 885 | 'std' => 1 |
| 886 | 886 | ), |
| 887 | 887 | 'email_completed_invoice_renewal_active' => array( |
| 888 | 888 | 'id' => 'email_completed_invoice_renewal_active', |
| 889 | - 'name' => __( 'Enable renewal notification', 'invoicing' ), |
|
| 890 | - 'desc' => __( 'Enable renewal invoice email notification. This notification will be sent on renewal.', 'invoicing' ), |
|
| 889 | + 'name' => __('Enable renewal notification', 'invoicing'), |
|
| 890 | + 'desc' => __('Enable renewal invoice email notification. This notification will be sent on renewal.', 'invoicing'), |
|
| 891 | 891 | 'type' => 'checkbox', |
| 892 | 892 | 'std' => 0 |
| 893 | 893 | ), |
| 894 | 894 | 'email_completed_invoice_subject' => array( |
| 895 | 895 | 'id' => 'email_completed_invoice_subject', |
| 896 | - 'name' => __( 'Subject', 'invoicing' ), |
|
| 897 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
| 896 | + 'name' => __('Subject', 'invoicing'), |
|
| 897 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
| 898 | 898 | 'type' => 'text', |
| 899 | - 'std' => __( '[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing' ), |
|
| 899 | + 'std' => __('[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing'), |
|
| 900 | 900 | 'size' => 'large' |
| 901 | 901 | ), |
| 902 | 902 | 'email_completed_invoice_heading' => array( |
| 903 | 903 | 'id' => 'email_completed_invoice_heading', |
| 904 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
| 905 | - 'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ), |
|
| 904 | + 'name' => __('Email Heading', 'invoicing'), |
|
| 905 | + 'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'), |
|
| 906 | 906 | 'type' => 'text', |
| 907 | - 'std' => __( 'Your invoice has been paid', 'invoicing' ), |
|
| 907 | + 'std' => __('Your invoice has been paid', 'invoicing'), |
|
| 908 | 908 | 'size' => 'large' |
| 909 | 909 | ), |
| 910 | 910 | 'email_completed_invoice_admin_bcc' => array( |
| 911 | 911 | 'id' => 'email_completed_invoice_admin_bcc', |
| 912 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
| 913 | - 'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ), |
|
| 912 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
| 913 | + 'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'), |
|
| 914 | 914 | 'type' => 'checkbox', |
| 915 | 915 | ), |
| 916 | 916 | 'email_completed_invoice_body' => array( |
| 917 | 917 | 'id' => 'email_completed_invoice_body', |
| 918 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
| 919 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
| 918 | + 'name' => __('Email Content', 'invoicing'), |
|
| 919 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
| 920 | 920 | 'type' => 'rich_editor', |
| 921 | - 'std' => __( '<p>Hi {name},</p><p>Your recent invoice on {site_title} has been paid.</p>', 'invoicing' ), |
|
| 921 | + 'std' => __('<p>Hi {name},</p><p>Your recent invoice on {site_title} has been paid.</p>', 'invoicing'), |
|
| 922 | 922 | 'class' => 'large', |
| 923 | 923 | 'size' => '10' |
| 924 | 924 | ), |
@@ -927,46 +927,46 @@ discard block |
||
| 927 | 927 | 'refunded_invoice' => array( |
| 928 | 928 | 'email_refunded_invoice_header' => array( |
| 929 | 929 | 'id' => 'email_refunded_invoice_header', |
| 930 | - 'name' => '<h3>' . __( 'Refunded Invoice', 'invoicing' ) . '</h3>', |
|
| 931 | - 'desc' => __( 'Invoice refunded emails are sent to users when their invoices are marked refunded.', 'invoicing' ), |
|
| 930 | + 'name' => '<h3>' . __('Refunded Invoice', 'invoicing') . '</h3>', |
|
| 931 | + 'desc' => __('Invoice refunded emails are sent to users when their invoices are marked refunded.', 'invoicing'), |
|
| 932 | 932 | 'type' => 'header', |
| 933 | 933 | ), |
| 934 | 934 | 'email_refunded_invoice_active' => array( |
| 935 | 935 | 'id' => 'email_refunded_invoice_active', |
| 936 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
| 937 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
| 936 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
| 937 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
| 938 | 938 | 'type' => 'checkbox', |
| 939 | 939 | 'std' => 1 |
| 940 | 940 | ), |
| 941 | 941 | 'email_refunded_invoice_subject' => array( |
| 942 | 942 | 'id' => 'email_refunded_invoice_subject', |
| 943 | - 'name' => __( 'Subject', 'invoicing' ), |
|
| 944 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
| 943 | + 'name' => __('Subject', 'invoicing'), |
|
| 944 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
| 945 | 945 | 'type' => 'text', |
| 946 | - 'std' => __( '[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing' ), |
|
| 946 | + 'std' => __('[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing'), |
|
| 947 | 947 | 'size' => 'large' |
| 948 | 948 | ), |
| 949 | 949 | 'email_refunded_invoice_heading' => array( |
| 950 | 950 | 'id' => 'email_refunded_invoice_heading', |
| 951 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
| 952 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
| 951 | + 'name' => __('Email Heading', 'invoicing'), |
|
| 952 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
| 953 | 953 | 'type' => 'text', |
| 954 | - 'std' => __( 'Your invoice has been refunded', 'invoicing' ), |
|
| 954 | + 'std' => __('Your invoice has been refunded', 'invoicing'), |
|
| 955 | 955 | 'size' => 'large' |
| 956 | 956 | ), |
| 957 | 957 | 'email_refunded_invoice_admin_bcc' => array( |
| 958 | 958 | 'id' => 'email_refunded_invoice_admin_bcc', |
| 959 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
| 960 | - 'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ), |
|
| 959 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
| 960 | + 'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'), |
|
| 961 | 961 | 'type' => 'checkbox', |
| 962 | 962 | 'std' => 1 |
| 963 | 963 | ), |
| 964 | 964 | 'email_refunded_invoice_body' => array( |
| 965 | 965 | 'id' => 'email_refunded_invoice_body', |
| 966 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
| 967 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
| 966 | + 'name' => __('Email Content', 'invoicing'), |
|
| 967 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
| 968 | 968 | 'type' => 'rich_editor', |
| 969 | - 'std' => __( '<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded.</p>', 'invoicing' ), |
|
| 969 | + 'std' => __('<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded.</p>', 'invoicing'), |
|
| 970 | 970 | 'class' => 'large', |
| 971 | 971 | 'size' => '10' |
| 972 | 972 | ), |
@@ -974,46 +974,46 @@ discard block |
||
| 974 | 974 | 'user_invoice' => array( |
| 975 | 975 | 'email_user_invoice_header' => array( |
| 976 | 976 | 'id' => 'email_user_invoice_header', |
| 977 | - 'name' => '<h3>' . __( 'Customer Invoice', 'invoicing' ) . '</h3>', |
|
| 978 | - 'desc' => __( 'Customer invoice emails can be sent to customers containing their invoice information and payment links.', 'invoicing' ), |
|
| 977 | + 'name' => '<h3>' . __('Customer Invoice', 'invoicing') . '</h3>', |
|
| 978 | + 'desc' => __('Customer invoice emails can be sent to customers containing their invoice information and payment links.', 'invoicing'), |
|
| 979 | 979 | 'type' => 'header', |
| 980 | 980 | ), |
| 981 | 981 | 'email_user_invoice_active' => array( |
| 982 | 982 | 'id' => 'email_user_invoice_active', |
| 983 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
| 984 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
| 983 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
| 984 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
| 985 | 985 | 'type' => 'checkbox', |
| 986 | 986 | 'std' => 1 |
| 987 | 987 | ), |
| 988 | 988 | 'email_user_invoice_subject' => array( |
| 989 | 989 | 'id' => 'email_user_invoice_subject', |
| 990 | - 'name' => __( 'Subject', 'invoicing' ), |
|
| 991 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
| 990 | + 'name' => __('Subject', 'invoicing'), |
|
| 991 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
| 992 | 992 | 'type' => 'text', |
| 993 | - 'std' => __( '[{site_title}] Your invoice from {invoice_date}', 'invoicing' ), |
|
| 993 | + 'std' => __('[{site_title}] Your invoice from {invoice_date}', 'invoicing'), |
|
| 994 | 994 | 'size' => 'large' |
| 995 | 995 | ), |
| 996 | 996 | 'email_user_invoice_heading' => array( |
| 997 | 997 | 'id' => 'email_user_invoice_heading', |
| 998 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
| 999 | - 'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ), |
|
| 998 | + 'name' => __('Email Heading', 'invoicing'), |
|
| 999 | + 'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'), |
|
| 1000 | 1000 | 'type' => 'text', |
| 1001 | - 'std' => __( 'Your invoice {invoice_number} details', 'invoicing' ), |
|
| 1001 | + 'std' => __('Your invoice {invoice_number} details', 'invoicing'), |
|
| 1002 | 1002 | 'size' => 'large' |
| 1003 | 1003 | ), |
| 1004 | 1004 | 'email_user_invoice_admin_bcc' => array( |
| 1005 | 1005 | 'id' => 'email_user_invoice_admin_bcc', |
| 1006 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
| 1007 | - 'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ), |
|
| 1006 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
| 1007 | + 'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'), |
|
| 1008 | 1008 | 'type' => 'checkbox', |
| 1009 | 1009 | 'std' => 1 |
| 1010 | 1010 | ), |
| 1011 | 1011 | 'email_user_invoice_body' => array( |
| 1012 | 1012 | 'id' => 'email_user_invoice_body', |
| 1013 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
| 1014 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
| 1013 | + 'name' => __('Email Content', 'invoicing'), |
|
| 1014 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
| 1015 | 1015 | 'type' => 'rich_editor', |
| 1016 | - 'std' => __( '<p>Hi {name},</p><p>An invoice has been created for you on {site_title}. To view / pay for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing' ), |
|
| 1016 | + 'std' => __('<p>Hi {name},</p><p>An invoice has been created for you on {site_title}. To view / pay for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing'), |
|
| 1017 | 1017 | 'class' => 'large', |
| 1018 | 1018 | 'size' => '10' |
| 1019 | 1019 | ), |
@@ -1021,39 +1021,39 @@ discard block |
||
| 1021 | 1021 | 'user_note' => array( |
| 1022 | 1022 | 'email_user_note_header' => array( |
| 1023 | 1023 | 'id' => 'email_user_note_header', |
| 1024 | - 'name' => '<h3>' . __( 'Customer Note', 'invoicing' ) . '</h3>', |
|
| 1025 | - 'desc' => __( 'Customer note emails are sent when you add a note to an invoice/quote.', 'invoicing' ), |
|
| 1024 | + 'name' => '<h3>' . __('Customer Note', 'invoicing') . '</h3>', |
|
| 1025 | + 'desc' => __('Customer note emails are sent when you add a note to an invoice/quote.', 'invoicing'), |
|
| 1026 | 1026 | 'type' => 'header', |
| 1027 | 1027 | ), |
| 1028 | 1028 | 'email_user_note_active' => array( |
| 1029 | 1029 | 'id' => 'email_user_note_active', |
| 1030 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
| 1031 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
| 1030 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
| 1031 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
| 1032 | 1032 | 'type' => 'checkbox', |
| 1033 | 1033 | 'std' => 1 |
| 1034 | 1034 | ), |
| 1035 | 1035 | 'email_user_note_subject' => array( |
| 1036 | 1036 | 'id' => 'email_user_note_subject', |
| 1037 | - 'name' => __( 'Subject', 'invoicing' ), |
|
| 1038 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
| 1037 | + 'name' => __('Subject', 'invoicing'), |
|
| 1038 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
| 1039 | 1039 | 'type' => 'text', |
| 1040 | - 'std' => __( '[{site_title}] Note added to your {invoice_label} #{invoice_number} from {invoice_date}', 'invoicing' ), |
|
| 1040 | + 'std' => __('[{site_title}] Note added to your {invoice_label} #{invoice_number} from {invoice_date}', 'invoicing'), |
|
| 1041 | 1041 | 'size' => 'large' |
| 1042 | 1042 | ), |
| 1043 | 1043 | 'email_user_note_heading' => array( |
| 1044 | 1044 | 'id' => 'email_user_note_heading', |
| 1045 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
| 1046 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
| 1045 | + 'name' => __('Email Heading', 'invoicing'), |
|
| 1046 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
| 1047 | 1047 | 'type' => 'text', |
| 1048 | - 'std' => __( 'A note has been added to your {invoice_label}', 'invoicing' ), |
|
| 1048 | + 'std' => __('A note has been added to your {invoice_label}', 'invoicing'), |
|
| 1049 | 1049 | 'size' => 'large' |
| 1050 | 1050 | ), |
| 1051 | 1051 | 'email_user_note_body' => array( |
| 1052 | 1052 | 'id' => 'email_user_note_body', |
| 1053 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
| 1054 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
| 1053 | + 'name' => __('Email Content', 'invoicing'), |
|
| 1054 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
| 1055 | 1055 | 'type' => 'rich_editor', |
| 1056 | - 'std' => __( '<p>Hi {name},</p><p>Following note has been added to your {invoice_label}:</p><blockquote class="wpinv-note">{customer_note}</blockquote>', 'invoicing' ), |
|
| 1056 | + 'std' => __('<p>Hi {name},</p><p>Following note has been added to your {invoice_label}:</p><blockquote class="wpinv-note">{customer_note}</blockquote>', 'invoicing'), |
|
| 1057 | 1057 | 'class' => 'large', |
| 1058 | 1058 | 'size' => '10' |
| 1059 | 1059 | ), |
@@ -1062,54 +1062,54 @@ discard block |
||
| 1062 | 1062 | 'pre_payment' => array( |
| 1063 | 1063 | 'email_pre_payment_header' => array( |
| 1064 | 1064 | 'id' => 'email_pre_payment_header', |
| 1065 | - 'name' => '<h3>' . __( 'Renewal Reminder', 'invoicing' ) . '</h3>', |
|
| 1066 | - 'desc' => __( 'Renewal reminder emails are sent to user automatically.', 'invoicing' ), |
|
| 1065 | + 'name' => '<h3>' . __('Renewal Reminder', 'invoicing') . '</h3>', |
|
| 1066 | + 'desc' => __('Renewal reminder emails are sent to user automatically.', 'invoicing'), |
|
| 1067 | 1067 | 'type' => 'header', |
| 1068 | 1068 | ), |
| 1069 | 1069 | 'email_pre_payment_active' => array( |
| 1070 | 1070 | 'id' => 'email_pre_payment_active', |
| 1071 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
| 1072 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
| 1071 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
| 1072 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
| 1073 | 1073 | 'type' => 'checkbox', |
| 1074 | 1074 | 'std' => 1 |
| 1075 | 1075 | ), |
| 1076 | 1076 | 'email_pre_payment_reminder_days' => array( |
| 1077 | 1077 | 'id' => 'email_pre_payment_reminder_days', |
| 1078 | - 'name' => __( 'When to Send', 'invoicing' ), |
|
| 1079 | - 'desc' => __( 'Enter a comma separated list of days before renewal when this email should be sent.', 'invoicing' ), |
|
| 1078 | + 'name' => __('When to Send', 'invoicing'), |
|
| 1079 | + 'desc' => __('Enter a comma separated list of days before renewal when this email should be sent.', 'invoicing'), |
|
| 1080 | 1080 | 'default' => '', |
| 1081 | 1081 | 'type' => 'text', |
| 1082 | 1082 | 'std' => '1,5,10', |
| 1083 | 1083 | ), |
| 1084 | 1084 | 'email_pre_payment_subject' => array( |
| 1085 | 1085 | 'id' => 'email_pre_payment_subject', |
| 1086 | - 'name' => __( 'Subject', 'invoicing' ), |
|
| 1087 | - 'desc' => __( 'Enter the subject line for the email.', 'invoicing' ), |
|
| 1086 | + 'name' => __('Subject', 'invoicing'), |
|
| 1087 | + 'desc' => __('Enter the subject line for the email.', 'invoicing'), |
|
| 1088 | 1088 | 'type' => 'text', |
| 1089 | - 'std' => __( '[{site_title}] Renewal Reminder', 'invoicing' ), |
|
| 1089 | + 'std' => __('[{site_title}] Renewal Reminder', 'invoicing'), |
|
| 1090 | 1090 | 'size' => 'large' |
| 1091 | 1091 | ), |
| 1092 | 1092 | 'email_pre_payment_heading' => array( |
| 1093 | 1093 | 'id' => 'email_pre_payment_heading', |
| 1094 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
| 1095 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
| 1094 | + 'name' => __('Email Heading', 'invoicing'), |
|
| 1095 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
| 1096 | 1096 | 'type' => 'text', |
| 1097 | - 'std' => __( 'Upcoming renewal reminder', 'invoicing' ), |
|
| 1097 | + 'std' => __('Upcoming renewal reminder', 'invoicing'), |
|
| 1098 | 1098 | 'size' => 'large' |
| 1099 | 1099 | ), |
| 1100 | 1100 | 'email_pre_payment_admin_bcc' => array( |
| 1101 | 1101 | 'id' => 'email_pre_payment_admin_bcc', |
| 1102 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
| 1103 | - 'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ), |
|
| 1102 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
| 1103 | + 'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'), |
|
| 1104 | 1104 | 'type' => 'checkbox', |
| 1105 | 1105 | 'std' => 1 |
| 1106 | 1106 | ), |
| 1107 | 1107 | 'email_pre_payment_body' => array( |
| 1108 | 1108 | 'id' => 'email_pre_payment_body', |
| 1109 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
| 1110 | - 'desc' => __( 'The content of the email.', 'invoicing' ), |
|
| 1109 | + 'name' => __('Email Content', 'invoicing'), |
|
| 1110 | + 'desc' => __('The content of the email.', 'invoicing'), |
|
| 1111 | 1111 | 'type' => 'rich_editor', |
| 1112 | - 'std' => __( '<p>Hi {full_name},</p><p>Your subscription for invoice <a href="{invoice_link}">#{invoice_number}</a> will renew on {subscription_renewal_date}.</p>', 'invoicing' ), |
|
| 1112 | + 'std' => __('<p>Hi {full_name},</p><p>Your subscription for invoice <a href="{invoice_link}">#{invoice_number}</a> will renew on {subscription_renewal_date}.</p>', 'invoicing'), |
|
| 1113 | 1113 | 'class' => 'large', |
| 1114 | 1114 | 'size' => 10, |
| 1115 | 1115 | ), |
@@ -1118,165 +1118,165 @@ discard block |
||
| 1118 | 1118 | 'overdue' => array( |
| 1119 | 1119 | 'email_overdue_header' => array( |
| 1120 | 1120 | 'id' => 'email_overdue_header', |
| 1121 | - 'name' => '<h3>' . __( 'Payment Reminder', 'invoicing' ) . '</h3>', |
|
| 1122 | - 'desc' => __( 'Payment reminder emails are sent to user automatically.', 'invoicing' ), |
|
| 1121 | + 'name' => '<h3>' . __('Payment Reminder', 'invoicing') . '</h3>', |
|
| 1122 | + 'desc' => __('Payment reminder emails are sent to user automatically.', 'invoicing'), |
|
| 1123 | 1123 | 'type' => 'header', |
| 1124 | 1124 | ), |
| 1125 | 1125 | 'email_overdue_active' => array( |
| 1126 | 1126 | 'id' => 'email_overdue_active', |
| 1127 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
| 1128 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
| 1127 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
| 1128 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
| 1129 | 1129 | 'type' => 'checkbox', |
| 1130 | 1130 | 'std' => 1 |
| 1131 | 1131 | ), |
| 1132 | 1132 | 'email_due_reminder_days' => array( |
| 1133 | 1133 | 'id' => 'email_due_reminder_days', |
| 1134 | - 'name' => __( 'When to Send', 'invoicing' ), |
|
| 1135 | - 'desc' => __( 'Check when you would like payment reminders sent out.', 'invoicing' ), |
|
| 1134 | + 'name' => __('When to Send', 'invoicing'), |
|
| 1135 | + 'desc' => __('Check when you would like payment reminders sent out.', 'invoicing'), |
|
| 1136 | 1136 | 'default' => '', |
| 1137 | 1137 | 'type' => 'multicheck', |
| 1138 | 1138 | 'options' => $overdue_days_options, |
| 1139 | 1139 | ), |
| 1140 | 1140 | 'email_overdue_subject' => array( |
| 1141 | 1141 | 'id' => 'email_overdue_subject', |
| 1142 | - 'name' => __( 'Subject', 'invoicing' ), |
|
| 1143 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
| 1142 | + 'name' => __('Subject', 'invoicing'), |
|
| 1143 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
| 1144 | 1144 | 'type' => 'text', |
| 1145 | - 'std' => __( '[{site_title}] Payment Reminder', 'invoicing' ), |
|
| 1145 | + 'std' => __('[{site_title}] Payment Reminder', 'invoicing'), |
|
| 1146 | 1146 | 'size' => 'large' |
| 1147 | 1147 | ), |
| 1148 | 1148 | 'email_overdue_heading' => array( |
| 1149 | 1149 | 'id' => 'email_overdue_heading', |
| 1150 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
| 1151 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
| 1150 | + 'name' => __('Email Heading', 'invoicing'), |
|
| 1151 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
| 1152 | 1152 | 'type' => 'text', |
| 1153 | - 'std' => __( 'Payment reminder for your invoice', 'invoicing' ), |
|
| 1153 | + 'std' => __('Payment reminder for your invoice', 'invoicing'), |
|
| 1154 | 1154 | 'size' => 'large' |
| 1155 | 1155 | ), |
| 1156 | 1156 | 'email_overdue_admin_bcc' => array( |
| 1157 | 1157 | 'id' => 'email_overdue_admin_bcc', |
| 1158 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
| 1159 | - 'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ), |
|
| 1158 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
| 1159 | + 'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'), |
|
| 1160 | 1160 | 'type' => 'checkbox', |
| 1161 | 1161 | 'std' => 1 |
| 1162 | 1162 | ), |
| 1163 | 1163 | 'email_overdue_body' => array( |
| 1164 | 1164 | 'id' => 'email_overdue_body', |
| 1165 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
| 1166 | - 'desc' => __( 'The content of the email.', 'invoicing' ), |
|
| 1165 | + 'name' => __('Email Content', 'invoicing'), |
|
| 1166 | + 'desc' => __('The content of the email.', 'invoicing'), |
|
| 1167 | 1167 | 'type' => 'rich_editor', |
| 1168 | - 'std' => __( '<p>Hi {full_name},</p><p>This is just a friendly reminder that your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing' ), |
|
| 1168 | + 'std' => __('<p>Hi {full_name},</p><p>This is just a friendly reminder that your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing'), |
|
| 1169 | 1169 | 'class' => 'large', |
| 1170 | 1170 | 'size' => 10, |
| 1171 | 1171 | ), |
| 1172 | 1172 | ), |
| 1173 | 1173 | ); |
| 1174 | 1174 | |
| 1175 | - return apply_filters( 'wpinv_get_emails', $emails ); |
|
| 1175 | + return apply_filters('wpinv_get_emails', $emails); |
|
| 1176 | 1176 | } |
| 1177 | 1177 | |
| 1178 | -function wpinv_settings_emails( $settings = array() ) { |
|
| 1178 | +function wpinv_settings_emails($settings = array()) { |
|
| 1179 | 1179 | $emails = wpinv_get_emails(); |
| 1180 | 1180 | |
| 1181 | - if ( !empty( $emails ) ) { |
|
| 1182 | - foreach ( $emails as $key => $email ) { |
|
| 1181 | + if (!empty($emails)) { |
|
| 1182 | + foreach ($emails as $key => $email) { |
|
| 1183 | 1183 | $settings[$key] = $email; |
| 1184 | 1184 | } |
| 1185 | 1185 | } |
| 1186 | 1186 | |
| 1187 | - return apply_filters( 'wpinv_settings_get_emails', $settings ); |
|
| 1187 | + return apply_filters('wpinv_settings_get_emails', $settings); |
|
| 1188 | 1188 | } |
| 1189 | -add_filter( 'wpinv_settings_emails', 'wpinv_settings_emails', 10, 1 ); |
|
| 1189 | +add_filter('wpinv_settings_emails', 'wpinv_settings_emails', 10, 1); |
|
| 1190 | 1190 | |
| 1191 | -function wpinv_settings_sections_emails( $settings ) { |
|
| 1191 | +function wpinv_settings_sections_emails($settings) { |
|
| 1192 | 1192 | $emails = wpinv_get_emails(); |
| 1193 | 1193 | |
| 1194 | 1194 | if (!empty($emails)) { |
| 1195 | - foreach ($emails as $key => $email) { |
|
| 1196 | - $settings[$key] = !empty( $email['email_' . $key . '_header']['name'] ) ? strip_tags( $email['email_' . $key . '_header']['name'] ) : $key; |
|
| 1195 | + foreach ($emails as $key => $email) { |
|
| 1196 | + $settings[$key] = !empty($email['email_' . $key . '_header']['name']) ? strip_tags($email['email_' . $key . '_header']['name']) : $key; |
|
| 1197 | 1197 | } |
| 1198 | 1198 | } |
| 1199 | 1199 | |
| 1200 | 1200 | return $settings; |
| 1201 | 1201 | } |
| 1202 | -add_filter( 'wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1 ); |
|
| 1202 | +add_filter('wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1); |
|
| 1203 | 1203 | |
| 1204 | -function wpinv_email_is_enabled( $email_type ) { |
|
| 1204 | +function wpinv_email_is_enabled($email_type) { |
|
| 1205 | 1205 | $emails = wpinv_get_emails(); |
| 1206 | - $enabled = isset( $emails[$email_type] ) && wpinv_get_option( 'email_'. $email_type . '_active', 0 ) ? true : false; |
|
| 1206 | + $enabled = isset($emails[$email_type]) && wpinv_get_option('email_' . $email_type . '_active', 0) ? true : false; |
|
| 1207 | 1207 | |
| 1208 | - return apply_filters( 'wpinv_email_is_enabled', $enabled, $email_type ); |
|
| 1208 | + return apply_filters('wpinv_email_is_enabled', $enabled, $email_type); |
|
| 1209 | 1209 | } |
| 1210 | 1210 | |
| 1211 | -function wpinv_email_get_recipient( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
| 1212 | - switch ( $email_type ) { |
|
| 1211 | +function wpinv_email_get_recipient($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
| 1212 | + switch ($email_type) { |
|
| 1213 | 1213 | case 'new_invoice': |
| 1214 | 1214 | case 'cancelled_invoice': |
| 1215 | 1215 | case 'failed_invoice': |
| 1216 | 1216 | $recipient = wpinv_get_admin_email(); |
| 1217 | 1217 | break; |
| 1218 | 1218 | default: |
| 1219 | - $invoice = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL ); |
|
| 1220 | - $recipient = !empty( $invoice ) ? $invoice->get_email() : ''; |
|
| 1219 | + $invoice = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL); |
|
| 1220 | + $recipient = !empty($invoice) ? $invoice->get_email() : ''; |
|
| 1221 | 1221 | break; |
| 1222 | 1222 | } |
| 1223 | 1223 | |
| 1224 | - return apply_filters( 'wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice ); |
|
| 1224 | + return apply_filters('wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice); |
|
| 1225 | 1225 | } |
| 1226 | 1226 | |
| 1227 | -function wpinv_email_get_subject( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
| 1228 | - $subject = wpinv_get_option( 'email_' . $email_type . '_subject' ); |
|
| 1229 | - $subject = __( $subject, 'invoicing' ); |
|
| 1227 | +function wpinv_email_get_subject($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
| 1228 | + $subject = wpinv_get_option('email_' . $email_type . '_subject'); |
|
| 1229 | + $subject = __($subject, 'invoicing'); |
|
| 1230 | 1230 | |
| 1231 | - $subject = wpinv_email_format_text( $subject, $invoice ); |
|
| 1231 | + $subject = wpinv_email_format_text($subject, $invoice); |
|
| 1232 | 1232 | |
| 1233 | - return apply_filters( 'wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice ); |
|
| 1233 | + return apply_filters('wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice); |
|
| 1234 | 1234 | } |
| 1235 | 1235 | |
| 1236 | -function wpinv_email_get_heading( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
| 1237 | - $email_heading = wpinv_get_option( 'email_' . $email_type . '_heading' ); |
|
| 1238 | - $email_heading = __( $email_heading, 'invoicing' ); |
|
| 1236 | +function wpinv_email_get_heading($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
| 1237 | + $email_heading = wpinv_get_option('email_' . $email_type . '_heading'); |
|
| 1238 | + $email_heading = __($email_heading, 'invoicing'); |
|
| 1239 | 1239 | |
| 1240 | - $email_heading = wpinv_email_format_text( $email_heading, $invoice ); |
|
| 1240 | + $email_heading = wpinv_email_format_text($email_heading, $invoice); |
|
| 1241 | 1241 | |
| 1242 | - return apply_filters( 'wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice ); |
|
| 1242 | + return apply_filters('wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice); |
|
| 1243 | 1243 | } |
| 1244 | 1244 | |
| 1245 | -function wpinv_email_get_content( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
| 1246 | - $content = wpinv_get_option( 'email_' . $email_type . '_body' ); |
|
| 1247 | - $content = __( $content, 'invoicing' ); |
|
| 1245 | +function wpinv_email_get_content($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
| 1246 | + $content = wpinv_get_option('email_' . $email_type . '_body'); |
|
| 1247 | + $content = __($content, 'invoicing'); |
|
| 1248 | 1248 | |
| 1249 | - $content = wpinv_email_format_text( $content, $invoice ); |
|
| 1249 | + $content = wpinv_email_format_text($content, $invoice); |
|
| 1250 | 1250 | |
| 1251 | - return apply_filters( 'wpinv_email_content', $content, $email_type, $invoice_id, $invoice ); |
|
| 1251 | + return apply_filters('wpinv_email_content', $content, $email_type, $invoice_id, $invoice); |
|
| 1252 | 1252 | } |
| 1253 | 1253 | |
| 1254 | -function wpinv_email_get_headers( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
| 1254 | +function wpinv_email_get_headers($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
| 1255 | 1255 | $from_name = wpinv_mail_get_from_address(); |
| 1256 | 1256 | $from_email = wpinv_mail_get_from_address(); |
| 1257 | 1257 | |
| 1258 | - $invoice = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL ); |
|
| 1258 | + $invoice = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL); |
|
| 1259 | 1259 | |
| 1260 | - $headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n"; |
|
| 1261 | - $headers .= "Reply-To: ". $from_email . "\r\n"; |
|
| 1260 | + $headers = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <$from_email>\r\n"; |
|
| 1261 | + $headers .= "Reply-To: " . $from_email . "\r\n"; |
|
| 1262 | 1262 | $headers .= "Content-Type: " . wpinv_mail_get_content_type() . "\r\n"; |
| 1263 | 1263 | |
| 1264 | - return apply_filters( 'wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice ); |
|
| 1264 | + return apply_filters('wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice); |
|
| 1265 | 1265 | } |
| 1266 | 1266 | |
| 1267 | -function wpinv_email_get_attachments( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
| 1267 | +function wpinv_email_get_attachments($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
| 1268 | 1268 | $attachments = array(); |
| 1269 | 1269 | |
| 1270 | - return apply_filters( 'wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice ); |
|
| 1270 | + return apply_filters('wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice); |
|
| 1271 | 1271 | } |
| 1272 | 1272 | |
| 1273 | -function wpinv_email_format_text( $content, $invoice ) { |
|
| 1273 | +function wpinv_email_format_text($content, $invoice) { |
|
| 1274 | 1274 | $replace_array = array( |
| 1275 | 1275 | '{site_title}' => wpinv_get_blogname(), |
| 1276 | - '{date}' => date_i18n( get_option( 'date_format' ), (int) current_time( 'timestamp' ) ), |
|
| 1276 | + '{date}' => date_i18n(get_option('date_format'), (int) current_time('timestamp')), |
|
| 1277 | 1277 | ); |
| 1278 | 1278 | |
| 1279 | - if ( !empty( $invoice->ID ) ) { |
|
| 1279 | + if (!empty($invoice->ID)) { |
|
| 1280 | 1280 | $replace_array = array_merge( |
| 1281 | 1281 | $replace_array, |
| 1282 | 1282 | array( |
@@ -1286,65 +1286,65 @@ discard block |
||
| 1286 | 1286 | '{last_name}' => $invoice->get_last_name(), |
| 1287 | 1287 | '{email}' => $invoice->get_email(), |
| 1288 | 1288 | '{invoice_number}' => $invoice->get_number(), |
| 1289 | - '{invoice_total}' => $invoice->get_total( true ), |
|
| 1290 | - '{invoice_link}' => $invoice->get_view_url( true ), |
|
| 1291 | - '{invoice_pay_link}'=> $invoice->get_view_url( true ), |
|
| 1292 | - '{invoice_date}' => $invoice->get_invoice_date( true ), |
|
| 1293 | - '{invoice_due_date}'=> $invoice->get_due_date( true ), |
|
| 1294 | - '{invoice_quote}' => $invoice->get_invoice_quote_type( $invoice->ID ), |
|
| 1295 | - '{invoice_label}' => $invoice->get_invoice_quote_type( $invoice->ID ), |
|
| 1296 | - '{is_was}' => strtotime( $invoice->get_due_date() ) < strtotime( date_i18n( 'Y-m-d' ) ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ), |
|
| 1289 | + '{invoice_total}' => $invoice->get_total(true), |
|
| 1290 | + '{invoice_link}' => $invoice->get_view_url(true), |
|
| 1291 | + '{invoice_pay_link}'=> $invoice->get_view_url(true), |
|
| 1292 | + '{invoice_date}' => $invoice->get_invoice_date(true), |
|
| 1293 | + '{invoice_due_date}'=> $invoice->get_due_date(true), |
|
| 1294 | + '{invoice_quote}' => $invoice->get_invoice_quote_type($invoice->ID), |
|
| 1295 | + '{invoice_label}' => $invoice->get_invoice_quote_type($invoice->ID), |
|
| 1296 | + '{is_was}' => strtotime($invoice->get_due_date()) < strtotime(date_i18n('Y-m-d')) ? __('was', 'invoicing') : __('is', 'invoicing'), |
|
| 1297 | 1297 | ) |
| 1298 | 1298 | ); |
| 1299 | 1299 | } |
| 1300 | 1300 | |
| 1301 | - $replace_array = apply_filters( 'wpinv_email_format_text', $replace_array, $content, $invoice ); |
|
| 1301 | + $replace_array = apply_filters('wpinv_email_format_text', $replace_array, $content, $invoice); |
|
| 1302 | 1302 | |
| 1303 | - foreach ( $replace_array as $key => $value ) { |
|
| 1304 | - $content = str_replace( $key, $value, $content ); |
|
| 1303 | + foreach ($replace_array as $key => $value) { |
|
| 1304 | + $content = str_replace($key, $value, $content); |
|
| 1305 | 1305 | } |
| 1306 | 1306 | |
| 1307 | - return apply_filters( 'wpinv_email_content_replace', $content ); |
|
| 1307 | + return apply_filters('wpinv_email_content_replace', $content); |
|
| 1308 | 1308 | } |
| 1309 | 1309 | |
| 1310 | -function wpinv_email_style_body( $content ) { |
|
| 1310 | +function wpinv_email_style_body($content) { |
|
| 1311 | 1311 | // make sure we only inline CSS for html emails |
| 1312 | - if ( in_array( wpinv_mail_get_content_type(), array( 'text/html', 'multipart/alternative' ) ) && class_exists( 'DOMDocument' ) ) { |
|
| 1312 | + if (in_array(wpinv_mail_get_content_type(), array('text/html', 'multipart/alternative')) && class_exists('DOMDocument')) { |
|
| 1313 | 1313 | ob_start(); |
| 1314 | - wpinv_get_template( 'emails/wpinv-email-styles.php' ); |
|
| 1315 | - $css = apply_filters( 'wpinv_email_styles', ob_get_clean() ); |
|
| 1314 | + wpinv_get_template('emails/wpinv-email-styles.php'); |
|
| 1315 | + $css = apply_filters('wpinv_email_styles', ob_get_clean()); |
|
| 1316 | 1316 | |
| 1317 | 1317 | // apply CSS styles inline for picky email clients |
| 1318 | 1318 | try { |
| 1319 | - $emogrifier = new Emogrifier( $content, $css ); |
|
| 1319 | + $emogrifier = new Emogrifier($content, $css); |
|
| 1320 | 1320 | $content = $emogrifier->emogrify(); |
| 1321 | - } catch ( Exception $e ) { |
|
| 1322 | - wpinv_error_log( $e->getMessage(), 'emogrifier' ); |
|
| 1321 | + } catch (Exception $e) { |
|
| 1322 | + wpinv_error_log($e->getMessage(), 'emogrifier'); |
|
| 1323 | 1323 | } |
| 1324 | 1324 | } |
| 1325 | 1325 | return $content; |
| 1326 | 1326 | } |
| 1327 | 1327 | |
| 1328 | -function wpinv_email_header( $email_heading = '', $invoice = array(), $email_type = '', $sent_to_admin = false ) { |
|
| 1329 | - wpinv_get_template( 'emails/wpinv-email-header.php', array( 'email_heading' => $email_heading, 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) ); |
|
| 1328 | +function wpinv_email_header($email_heading = '', $invoice = array(), $email_type = '', $sent_to_admin = false) { |
|
| 1329 | + wpinv_get_template('emails/wpinv-email-header.php', array('email_heading' => $email_heading, 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin)); |
|
| 1330 | 1330 | } |
| 1331 | 1331 | |
| 1332 | 1332 | /** |
| 1333 | 1333 | * Get the email footer. |
| 1334 | 1334 | */ |
| 1335 | -function wpinv_email_footer( $invoice = array(), $email_type = '', $sent_to_admin = false ) { |
|
| 1336 | - wpinv_get_template( 'emails/wpinv-email-footer.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) ); |
|
| 1335 | +function wpinv_email_footer($invoice = array(), $email_type = '', $sent_to_admin = false) { |
|
| 1336 | + wpinv_get_template('emails/wpinv-email-footer.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin)); |
|
| 1337 | 1337 | } |
| 1338 | 1338 | |
| 1339 | -function wpinv_email_wrap_message( $message ) { |
|
| 1339 | +function wpinv_email_wrap_message($message) { |
|
| 1340 | 1340 | // Buffer |
| 1341 | 1341 | ob_start(); |
| 1342 | 1342 | |
| 1343 | - do_action( 'wpinv_email_header' ); |
|
| 1343 | + do_action('wpinv_email_header'); |
|
| 1344 | 1344 | |
| 1345 | - echo wpautop( wptexturize( $message ) ); |
|
| 1345 | + echo wpautop(wptexturize($message)); |
|
| 1346 | 1346 | |
| 1347 | - do_action( 'wpinv_email_footer' ); |
|
| 1347 | + do_action('wpinv_email_footer'); |
|
| 1348 | 1348 | |
| 1349 | 1349 | // Get contents |
| 1350 | 1350 | $message = ob_get_clean(); |
@@ -1352,92 +1352,92 @@ discard block |
||
| 1352 | 1352 | return $message; |
| 1353 | 1353 | } |
| 1354 | 1354 | |
| 1355 | -function wpinv_email_invoice_details( $invoice, $email_type = '', $sent_to_admin = false ) { |
|
| 1356 | - wpinv_get_template( 'emails/wpinv-email-invoice-details.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) ); |
|
| 1355 | +function wpinv_email_invoice_details($invoice, $email_type = '', $sent_to_admin = false) { |
|
| 1356 | + wpinv_get_template('emails/wpinv-email-invoice-details.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin)); |
|
| 1357 | 1357 | } |
| 1358 | 1358 | |
| 1359 | -function wpinv_email_invoice_items( $invoice, $email_type = '', $sent_to_admin = false ) { |
|
| 1360 | - wpinv_get_template( 'emails/wpinv-email-invoice-items.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) ); |
|
| 1359 | +function wpinv_email_invoice_items($invoice, $email_type = '', $sent_to_admin = false) { |
|
| 1360 | + wpinv_get_template('emails/wpinv-email-invoice-items.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin)); |
|
| 1361 | 1361 | } |
| 1362 | 1362 | |
| 1363 | -function wpinv_email_billing_details( $invoice, $email_type = '', $sent_to_admin = false ) { |
|
| 1364 | - wpinv_get_template( 'emails/wpinv-email-billing-details.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) ); |
|
| 1363 | +function wpinv_email_billing_details($invoice, $email_type = '', $sent_to_admin = false) { |
|
| 1364 | + wpinv_get_template('emails/wpinv-email-billing-details.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin)); |
|
| 1365 | 1365 | } |
| 1366 | 1366 | |
| 1367 | -function wpinv_send_customer_invoice( $data = array() ) { |
|
| 1368 | - $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL; |
|
| 1367 | +function wpinv_send_customer_invoice($data = array()) { |
|
| 1368 | + $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL; |
|
| 1369 | 1369 | |
| 1370 | - if ( empty( $invoice_id ) ) { |
|
| 1370 | + if (empty($invoice_id)) { |
|
| 1371 | 1371 | return; |
| 1372 | 1372 | } |
| 1373 | 1373 | |
| 1374 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
| 1375 | - wp_die( __( 'You do not have permission to send invoice notification', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
| 1374 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 1375 | + wp_die(__('You do not have permission to send invoice notification', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
| 1376 | 1376 | } |
| 1377 | 1377 | |
| 1378 | - $sent = wpinv_user_invoice_notification( $invoice_id ); |
|
| 1378 | + $sent = wpinv_user_invoice_notification($invoice_id); |
|
| 1379 | 1379 | |
| 1380 | 1380 | if ( -1 === $sent ) { |
| 1381 | 1381 | $status = 'email_disabled'; |
| 1382 | - } elseif ( $sent ) { |
|
| 1382 | + } elseif ($sent) { |
|
| 1383 | 1383 | $status = 'email_sent'; |
| 1384 | 1384 | } else { |
| 1385 | 1385 | $status = 'email_fail'; |
| 1386 | 1386 | } |
| 1387 | 1387 | |
| 1388 | - $redirect = add_query_arg( array( 'wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false ) ); |
|
| 1389 | - wp_redirect( $redirect ); |
|
| 1388 | + $redirect = add_query_arg(array('wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false)); |
|
| 1389 | + wp_redirect($redirect); |
|
| 1390 | 1390 | exit; |
| 1391 | 1391 | } |
| 1392 | -add_action( 'wpinv_send_invoice', 'wpinv_send_customer_invoice' ); |
|
| 1392 | +add_action('wpinv_send_invoice', 'wpinv_send_customer_invoice'); |
|
| 1393 | 1393 | |
| 1394 | -function wpinv_send_overdue_reminder( $data = array() ) { |
|
| 1395 | - $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL; |
|
| 1394 | +function wpinv_send_overdue_reminder($data = array()) { |
|
| 1395 | + $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL; |
|
| 1396 | 1396 | |
| 1397 | - if ( empty( $invoice_id ) ) { |
|
| 1397 | + if (empty($invoice_id)) { |
|
| 1398 | 1398 | return; |
| 1399 | 1399 | } |
| 1400 | 1400 | |
| 1401 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
| 1402 | - wp_die( __( 'You do not have permission to send reminder notification', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
| 1401 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 1402 | + wp_die(__('You do not have permission to send reminder notification', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
| 1403 | 1403 | } |
| 1404 | 1404 | |
| 1405 | - $sent = wpinv_send_payment_reminder_notification( $invoice_id ); |
|
| 1405 | + $sent = wpinv_send_payment_reminder_notification($invoice_id); |
|
| 1406 | 1406 | |
| 1407 | 1407 | $status = $sent ? 'email_sent' : 'email_fail'; |
| 1408 | 1408 | |
| 1409 | - $redirect = add_query_arg( array( 'wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false ) ); |
|
| 1410 | - wp_redirect( $redirect ); |
|
| 1409 | + $redirect = add_query_arg(array('wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false)); |
|
| 1410 | + wp_redirect($redirect); |
|
| 1411 | 1411 | exit; |
| 1412 | 1412 | } |
| 1413 | -add_action( 'wpinv_send_reminder', 'wpinv_send_overdue_reminder' ); |
|
| 1413 | +add_action('wpinv_send_reminder', 'wpinv_send_overdue_reminder'); |
|
| 1414 | 1414 | |
| 1415 | -function wpinv_send_customer_note_email( $data ) { |
|
| 1416 | - $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL; |
|
| 1415 | +function wpinv_send_customer_note_email($data) { |
|
| 1416 | + $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL; |
|
| 1417 | 1417 | |
| 1418 | - if ( empty( $invoice_id ) ) { |
|
| 1418 | + if (empty($invoice_id)) { |
|
| 1419 | 1419 | return; |
| 1420 | 1420 | } |
| 1421 | 1421 | |
| 1422 | - $sent = wpinv_user_note_notification( $invoice_id, $data ); |
|
| 1422 | + $sent = wpinv_user_note_notification($invoice_id, $data); |
|
| 1423 | 1423 | } |
| 1424 | -add_action( 'wpinv_new_customer_note', 'wpinv_send_customer_note_email', 10, 1 ); |
|
| 1424 | +add_action('wpinv_new_customer_note', 'wpinv_send_customer_note_email', 10, 1); |
|
| 1425 | 1425 | |
| 1426 | -function wpinv_add_notes_to_invoice_email( $invoice, $email_type, $sent_to_admin ) { |
|
| 1427 | - if ( !empty( $invoice ) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes( $invoice->ID, true ) ) { |
|
| 1428 | - $date_format = get_option( 'date_format' ); |
|
| 1429 | - $time_format = get_option( 'time_format' ); |
|
| 1426 | +function wpinv_add_notes_to_invoice_email($invoice, $email_type, $sent_to_admin) { |
|
| 1427 | + if (!empty($invoice) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes($invoice->ID, true)) { |
|
| 1428 | + $date_format = get_option('date_format'); |
|
| 1429 | + $time_format = get_option('time_format'); |
|
| 1430 | 1430 | ?> |
| 1431 | 1431 | <div id="wpinv-email-notes"> |
| 1432 | - <h3 class="wpinv-notes-t"><?php echo apply_filters( 'wpinv_email_invoice_notes_title', __( 'Invoice Notes', 'invoicing' ) ); ?></h3> |
|
| 1432 | + <h3 class="wpinv-notes-t"><?php echo apply_filters('wpinv_email_invoice_notes_title', __('Invoice Notes', 'invoicing')); ?></h3> |
|
| 1433 | 1433 | <ol class="wpinv-notes-lists"> |
| 1434 | 1434 | <?php |
| 1435 | - foreach ( $invoice_notes as $note ) { |
|
| 1436 | - $note_time = strtotime( $note->comment_date ); |
|
| 1435 | + foreach ($invoice_notes as $note) { |
|
| 1436 | + $note_time = strtotime($note->comment_date); |
|
| 1437 | 1437 | ?> |
| 1438 | 1438 | <li class="comment wpinv-note"> |
| 1439 | - <p class="wpinv-note-date meta"><?php printf( __( '%2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( $date_format, $note_time ), date_i18n( $time_format, $note_time ), $note_time ); ?></p> |
|
| 1440 | - <div class="wpinv-note-desc description"><?php echo wpautop( wptexturize( $note->comment_content ) ); ?></div> |
|
| 1439 | + <p class="wpinv-note-date meta"><?php printf(__('%2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n($date_format, $note_time), date_i18n($time_format, $note_time), $note_time); ?></p> |
|
| 1440 | + <div class="wpinv-note-desc description"><?php echo wpautop(wptexturize($note->comment_content)); ?></div> |
|
| 1441 | 1441 | </li> |
| 1442 | 1442 | <?php |
| 1443 | 1443 | } |
@@ -1446,7 +1446,7 @@ discard block |
||
| 1446 | 1446 | <?php |
| 1447 | 1447 | } |
| 1448 | 1448 | } |
| 1449 | -add_action( 'wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3 ); |
|
| 1449 | +add_action('wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3); |
|
| 1450 | 1450 | |
| 1451 | 1451 | /** |
| 1452 | 1452 | * Sends renewal reminders. |
@@ -1454,35 +1454,35 @@ discard block |
||
| 1454 | 1454 | function wpinv_email_renewal_reminders() { |
| 1455 | 1455 | global $wpdb; |
| 1456 | 1456 | |
| 1457 | - if ( ! wpinv_get_option( 'email_pre_payment_active' ) ) { |
|
| 1457 | + if (!wpinv_get_option('email_pre_payment_active')) { |
|
| 1458 | 1458 | return; |
| 1459 | 1459 | } |
| 1460 | 1460 | |
| 1461 | - $reminder_days = wpinv_get_option( 'email_pre_payment_reminder_days' ); |
|
| 1461 | + $reminder_days = wpinv_get_option('email_pre_payment_reminder_days'); |
|
| 1462 | 1462 | |
| 1463 | - if ( empty( $reminder_days ) ) { |
|
| 1463 | + if (empty($reminder_days)) { |
|
| 1464 | 1464 | return; |
| 1465 | 1465 | } |
| 1466 | 1466 | |
| 1467 | 1467 | // How many days before renewal should we send this email? |
| 1468 | - $reminder_days = array_unique( array_map( 'absint', array_filter( wpinv_parse_list( $reminder_days ) ) ) ); |
|
| 1469 | - if ( empty( $reminder_days ) ) { |
|
| 1468 | + $reminder_days = array_unique(array_map('absint', array_filter(wpinv_parse_list($reminder_days)))); |
|
| 1469 | + if (empty($reminder_days)) { |
|
| 1470 | 1470 | return; |
| 1471 | 1471 | } |
| 1472 | 1472 | |
| 1473 | - if ( 1 == count( $reminder_days ) ) { |
|
| 1473 | + if (1 == count($reminder_days)) { |
|
| 1474 | 1474 | $days = $reminder_days[0]; |
| 1475 | - $date = date( 'Y-m-d', strtotime( "+$days days", current_time( 'timestamp' ) ) ); |
|
| 1476 | - $where = $wpdb->prepare( "DATE(expiration)=%s", $date ); |
|
| 1475 | + $date = date('Y-m-d', strtotime("+$days days", current_time('timestamp'))); |
|
| 1476 | + $where = $wpdb->prepare("DATE(expiration)=%s", $date); |
|
| 1477 | 1477 | } else { |
| 1478 | 1478 | $in = array(); |
| 1479 | 1479 | |
| 1480 | - foreach ( $reminder_days as $days ) { |
|
| 1481 | - $date = date( 'Y-m-d', strtotime( "+$days days", current_time( 'timestamp' ) ) ); |
|
| 1482 | - $in[] = $wpdb->prepare( "%s", $date ); |
|
| 1480 | + foreach ($reminder_days as $days) { |
|
| 1481 | + $date = date('Y-m-d', strtotime("+$days days", current_time('timestamp'))); |
|
| 1482 | + $in[] = $wpdb->prepare("%s", $date); |
|
| 1483 | 1483 | } |
| 1484 | 1484 | |
| 1485 | - $in = implode( ',', $in ); |
|
| 1485 | + $in = implode(',', $in); |
|
| 1486 | 1486 | $where = "DATE(expiration) IN ($in)"; |
| 1487 | 1487 | } |
| 1488 | 1488 | |
@@ -1490,20 +1490,20 @@ discard block |
||
| 1490 | 1490 | $table = $wpdb->prefix . 'wpinv_subscriptions'; |
| 1491 | 1491 | |
| 1492 | 1492 | // Fetch invoices. |
| 1493 | - $subscriptions = $wpdb->get_results( |
|
| 1493 | + $subscriptions = $wpdb->get_results( |
|
| 1494 | 1494 | "SELECT parent_payment_id, product_id, expiration FROM $table |
| 1495 | 1495 | WHERE |
| 1496 | 1496 | $where |
| 1497 | 1497 | AND status IN ( 'trialling', 'active' )"); |
| 1498 | 1498 | |
| 1499 | - foreach ( $subscriptions as $subscription ) { |
|
| 1499 | + foreach ($subscriptions as $subscription) { |
|
| 1500 | 1500 | |
| 1501 | 1501 | // Skip packages. |
| 1502 | - if ( get_post_meta( $subscription->product_id, '_wpinv_type', true ) == 'package' ) { |
|
| 1502 | + if (get_post_meta($subscription->product_id, '_wpinv_type', true) == 'package') { |
|
| 1503 | 1503 | continue; |
| 1504 | 1504 | } |
| 1505 | 1505 | |
| 1506 | - wpinv_send_pre_payment_reminder_notification( $subscription->parent_payment_id, $subscription->expiration ); |
|
| 1506 | + wpinv_send_pre_payment_reminder_notification($subscription->parent_payment_id, $subscription->expiration); |
|
| 1507 | 1507 | } |
| 1508 | 1508 | |
| 1509 | 1509 | } |
@@ -1511,44 +1511,44 @@ discard block |
||
| 1511 | 1511 | function wpinv_email_payment_reminders() { |
| 1512 | 1512 | global $wpi_auto_reminder, $wpdb; |
| 1513 | 1513 | |
| 1514 | - if ( ! wpinv_get_option( 'email_overdue_active' ) ) { |
|
| 1514 | + if (!wpinv_get_option('email_overdue_active')) { |
|
| 1515 | 1515 | return; |
| 1516 | 1516 | } |
| 1517 | 1517 | |
| 1518 | - if ( $reminder_days = wpinv_get_option( 'email_due_reminder_days' ) ) { |
|
| 1518 | + if ($reminder_days = wpinv_get_option('email_due_reminder_days')) { |
|
| 1519 | 1519 | |
| 1520 | 1520 | // Get a list of all reminder dates. |
| 1521 | - $reminder_days = is_array( $reminder_days ) ? array_values( $reminder_days ) : array(); |
|
| 1521 | + $reminder_days = is_array($reminder_days) ? array_values($reminder_days) : array(); |
|
| 1522 | 1522 | |
| 1523 | 1523 | // Ensure we have integers. |
| 1524 | - $reminder_days = array_unique( array_map( 'absint', $reminder_days ) ); |
|
| 1524 | + $reminder_days = array_unique(array_map('absint', $reminder_days)); |
|
| 1525 | 1525 | |
| 1526 | 1526 | // Abort if non is selected. |
| 1527 | - if ( empty( $reminder_days ) ) { |
|
| 1527 | + if (empty($reminder_days)) { |
|
| 1528 | 1528 | return; |
| 1529 | 1529 | } |
| 1530 | 1530 | |
| 1531 | 1531 | // Fetch the max reminder day. |
| 1532 | - $max_date = max( $reminder_days ); |
|
| 1532 | + $max_date = max($reminder_days); |
|
| 1533 | 1533 | |
| 1534 | 1534 | // Todays date. |
| 1535 | - $today = date( 'Y-m-d', current_time( 'timestamp' ) ); |
|
| 1535 | + $today = date('Y-m-d', current_time('timestamp')); |
|
| 1536 | 1536 | |
| 1537 | - if ( empty( $max_date ) ) { |
|
| 1538 | - $where = $wpdb->prepare( "DATE(invoices.due_date)=%s", $today ); |
|
| 1539 | - } else if ( 1 == count( $reminder_days ) ) { |
|
| 1537 | + if (empty($max_date)) { |
|
| 1538 | + $where = $wpdb->prepare("DATE(invoices.due_date)=%s", $today); |
|
| 1539 | + } else if (1 == count($reminder_days)) { |
|
| 1540 | 1540 | $days = $reminder_days[0]; |
| 1541 | - $date = date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
| 1542 | - $where = $wpdb->prepare( "DATE(invoices.due_date)=%s", $date ); |
|
| 1541 | + $date = date('Y-m-d', strtotime("-$days days", current_time('timestamp'))); |
|
| 1542 | + $where = $wpdb->prepare("DATE(invoices.due_date)=%s", $date); |
|
| 1543 | 1543 | } else { |
| 1544 | 1544 | $in = array(); |
| 1545 | 1545 | |
| 1546 | - foreach ( $reminder_days as $days ) { |
|
| 1547 | - $date = date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
| 1548 | - $in[] = $wpdb->prepare( "%s", $date ); |
|
| 1546 | + foreach ($reminder_days as $days) { |
|
| 1547 | + $date = date('Y-m-d', strtotime("-$days days", current_time('timestamp'))); |
|
| 1548 | + $in[] = $wpdb->prepare("%s", $date); |
|
| 1549 | 1549 | } |
| 1550 | 1550 | |
| 1551 | - $in = implode( ',', $in ); |
|
| 1551 | + $in = implode(',', $in); |
|
| 1552 | 1552 | $where = "DATE(invoices.due_date) IN ($in)"; |
| 1553 | 1553 | } |
| 1554 | 1554 | |
@@ -1556,7 +1556,7 @@ discard block |
||
| 1556 | 1556 | $table = $wpdb->prefix . 'getpaid_invoices'; |
| 1557 | 1557 | |
| 1558 | 1558 | // Fetch invoices. |
| 1559 | - $invoices = $wpdb->get_col( |
|
| 1559 | + $invoices = $wpdb->get_col( |
|
| 1560 | 1560 | "SELECT posts.ID FROM $wpdb->posts as posts |
| 1561 | 1561 | LEFT JOIN $table as invoices ON invoices.post_id = posts.ID |
| 1562 | 1562 | WHERE |
@@ -1564,174 +1564,174 @@ discard block |
||
| 1564 | 1564 | AND posts.post_type = 'wpi_invoice' |
| 1565 | 1565 | AND posts.post_status = 'wpi-pending'"); |
| 1566 | 1566 | |
| 1567 | - $wpi_auto_reminder = true; |
|
| 1567 | + $wpi_auto_reminder = true; |
|
| 1568 | 1568 | |
| 1569 | - foreach ( $invoices as $invoice ) { |
|
| 1569 | + foreach ($invoices as $invoice) { |
|
| 1570 | 1570 | |
| 1571 | - if ( 'payment_form' != get_post_meta( $invoice, 'wpinv_created_via', true ) ) { |
|
| 1572 | - do_action( 'wpinv_send_payment_reminder_notification', $invoice ); |
|
| 1571 | + if ('payment_form' != get_post_meta($invoice, 'wpinv_created_via', true)) { |
|
| 1572 | + do_action('wpinv_send_payment_reminder_notification', $invoice); |
|
| 1573 | 1573 | } |
| 1574 | 1574 | |
| 1575 | 1575 | } |
| 1576 | 1576 | |
| 1577 | - $wpi_auto_reminder = false; |
|
| 1577 | + $wpi_auto_reminder = false; |
|
| 1578 | 1578 | } |
| 1579 | 1579 | } |
| 1580 | 1580 | |
| 1581 | 1581 | /** |
| 1582 | 1582 | * Sends an upcoming renewal notification. |
| 1583 | 1583 | */ |
| 1584 | -function wpinv_send_pre_payment_reminder_notification( $invoice_id, $renewal_date ) { |
|
| 1584 | +function wpinv_send_pre_payment_reminder_notification($invoice_id, $renewal_date) { |
|
| 1585 | 1585 | |
| 1586 | 1586 | $email_type = 'pre_payment'; |
| 1587 | - if ( ! wpinv_email_is_enabled( $email_type ) ) { |
|
| 1587 | + if (!wpinv_email_is_enabled($email_type)) { |
|
| 1588 | 1588 | return false; |
| 1589 | 1589 | } |
| 1590 | 1590 | |
| 1591 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1592 | - if ( empty( $invoice ) ) { |
|
| 1591 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1592 | + if (empty($invoice)) { |
|
| 1593 | 1593 | return false; |
| 1594 | 1594 | } |
| 1595 | 1595 | |
| 1596 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
| 1597 | - if ( ! is_email( $recipient ) ) { |
|
| 1596 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
| 1597 | + if (!is_email($recipient)) { |
|
| 1598 | 1598 | return false; |
| 1599 | 1599 | } |
| 1600 | 1600 | |
| 1601 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
| 1602 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
| 1603 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
| 1604 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
| 1605 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
| 1601 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
| 1602 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
| 1603 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
| 1604 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
| 1605 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
| 1606 | 1606 | |
| 1607 | - $renewal_date = date_i18n( 'Y-m-d', strtotime( $renewal_date ) ); |
|
| 1608 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
| 1607 | + $renewal_date = date_i18n('Y-m-d', strtotime($renewal_date)); |
|
| 1608 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
| 1609 | 1609 | 'invoice' => $invoice, |
| 1610 | 1610 | 'email_type' => $email_type, |
| 1611 | - 'email_heading' => str_replace( '{subscription_renewal_date}', $renewal_date, $email_heading ), |
|
| 1611 | + 'email_heading' => str_replace('{subscription_renewal_date}', $renewal_date, $email_heading), |
|
| 1612 | 1612 | 'sent_to_admin' => false, |
| 1613 | 1613 | 'plain_text' => false, |
| 1614 | - 'message_body' => str_replace( '{subscription_renewal_date}', $renewal_date, $message_body ) |
|
| 1615 | - ) ); |
|
| 1614 | + 'message_body' => str_replace('{subscription_renewal_date}', $renewal_date, $message_body) |
|
| 1615 | + )); |
|
| 1616 | 1616 | |
| 1617 | - $content = wpinv_email_format_text( $content, $invoice ); |
|
| 1617 | + $content = wpinv_email_format_text($content, $invoice); |
|
| 1618 | 1618 | |
| 1619 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 1619 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 1620 | 1620 | |
| 1621 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
| 1622 | - $recipient = wpinv_get_admin_email(); |
|
| 1623 | - $subject .= ' - ADMIN BCC COPY'; |
|
| 1624 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 1621 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
| 1622 | + $recipient = wpinv_get_admin_email(); |
|
| 1623 | + $subject .= ' - ADMIN BCC COPY'; |
|
| 1624 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 1625 | 1625 | } |
| 1626 | 1626 | |
| 1627 | 1627 | return $sent; |
| 1628 | 1628 | |
| 1629 | 1629 | } |
| 1630 | 1630 | |
| 1631 | -function wpinv_send_payment_reminder_notification( $invoice_id ) { |
|
| 1631 | +function wpinv_send_payment_reminder_notification($invoice_id) { |
|
| 1632 | 1632 | $email_type = 'overdue'; |
| 1633 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
| 1633 | + if (!wpinv_email_is_enabled($email_type)) { |
|
| 1634 | 1634 | return false; |
| 1635 | 1635 | } |
| 1636 | 1636 | |
| 1637 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1638 | - if ( empty( $invoice ) ) { |
|
| 1637 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1638 | + if (empty($invoice)) { |
|
| 1639 | 1639 | return false; |
| 1640 | 1640 | } |
| 1641 | 1641 | |
| 1642 | - if ( !$invoice->needs_payment() ) { |
|
| 1642 | + if (!$invoice->needs_payment()) { |
|
| 1643 | 1643 | return false; |
| 1644 | 1644 | } |
| 1645 | 1645 | |
| 1646 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
| 1647 | - if ( !is_email( $recipient ) ) { |
|
| 1646 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
| 1647 | + if (!is_email($recipient)) { |
|
| 1648 | 1648 | return false; |
| 1649 | 1649 | } |
| 1650 | 1650 | |
| 1651 | - do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type ); |
|
| 1651 | + do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type); |
|
| 1652 | 1652 | |
| 1653 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
| 1654 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
| 1655 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
| 1656 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
| 1657 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
| 1653 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
| 1654 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
| 1655 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
| 1656 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
| 1657 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
| 1658 | 1658 | |
| 1659 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
| 1659 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
| 1660 | 1660 | 'invoice' => $invoice, |
| 1661 | 1661 | 'email_type' => $email_type, |
| 1662 | 1662 | 'email_heading' => $email_heading, |
| 1663 | 1663 | 'sent_to_admin' => false, |
| 1664 | 1664 | 'plain_text' => false, |
| 1665 | 1665 | 'message_body' => $message_body |
| 1666 | - ) ); |
|
| 1666 | + )); |
|
| 1667 | 1667 | |
| 1668 | - $content = wpinv_email_format_text( $content, $invoice ); |
|
| 1668 | + $content = wpinv_email_format_text($content, $invoice); |
|
| 1669 | 1669 | |
| 1670 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 1671 | - if ( $sent ) { |
|
| 1672 | - do_action( 'wpinv_payment_reminder_sent', $invoice_id, $invoice ); |
|
| 1670 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 1671 | + if ($sent) { |
|
| 1672 | + do_action('wpinv_payment_reminder_sent', $invoice_id, $invoice); |
|
| 1673 | 1673 | } |
| 1674 | 1674 | |
| 1675 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
| 1676 | - $recipient = wpinv_get_admin_email(); |
|
| 1677 | - $subject .= ' - ADMIN BCC COPY'; |
|
| 1678 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 1675 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
| 1676 | + $recipient = wpinv_get_admin_email(); |
|
| 1677 | + $subject .= ' - ADMIN BCC COPY'; |
|
| 1678 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 1679 | 1679 | } |
| 1680 | 1680 | |
| 1681 | - do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type ); |
|
| 1681 | + do_action('wpinv_post_send_invoice_notification', $invoice, $email_type); |
|
| 1682 | 1682 | |
| 1683 | 1683 | return $sent; |
| 1684 | 1684 | } |
| 1685 | -add_action( 'wpinv_send_payment_reminder_notification', 'wpinv_send_payment_reminder_notification', 10, 1 ); |
|
| 1685 | +add_action('wpinv_send_payment_reminder_notification', 'wpinv_send_payment_reminder_notification', 10, 1); |
|
| 1686 | 1686 | |
| 1687 | -function wpinv_payment_reminder_sent( $invoice_id, $invoice ) { |
|
| 1687 | +function wpinv_payment_reminder_sent($invoice_id, $invoice) { |
|
| 1688 | 1688 | global $wpi_auto_reminder; |
| 1689 | 1689 | |
| 1690 | - $sent = get_post_meta( $invoice_id, '_wpinv_reminder_sent', true ); |
|
| 1690 | + $sent = get_post_meta($invoice_id, '_wpinv_reminder_sent', true); |
|
| 1691 | 1691 | |
| 1692 | - if ( empty( $sent ) ) { |
|
| 1692 | + if (empty($sent)) { |
|
| 1693 | 1693 | $sent = array(); |
| 1694 | 1694 | } |
| 1695 | - $sent[] = date_i18n( 'Y-m-d' ); |
|
| 1695 | + $sent[] = date_i18n('Y-m-d'); |
|
| 1696 | 1696 | |
| 1697 | - update_post_meta( $invoice_id, '_wpinv_reminder_sent', $sent ); |
|
| 1697 | + update_post_meta($invoice_id, '_wpinv_reminder_sent', $sent); |
|
| 1698 | 1698 | |
| 1699 | - if ( $wpi_auto_reminder ) { // Auto reminder note. |
|
| 1700 | - $note = __( 'Automated reminder sent to the user.', 'invoicing' ); |
|
| 1701 | - $invoice->add_note( $note, false, false, true ); |
|
| 1699 | + if ($wpi_auto_reminder) { // Auto reminder note. |
|
| 1700 | + $note = __('Automated reminder sent to the user.', 'invoicing'); |
|
| 1701 | + $invoice->add_note($note, false, false, true); |
|
| 1702 | 1702 | } else { // Menual reminder note. |
| 1703 | - $note = __( 'Manual reminder sent to the user.', 'invoicing' ); |
|
| 1704 | - $invoice->add_note( $note ); |
|
| 1703 | + $note = __('Manual reminder sent to the user.', 'invoicing'); |
|
| 1704 | + $invoice->add_note($note); |
|
| 1705 | 1705 | } |
| 1706 | 1706 | } |
| 1707 | -add_action( 'wpinv_payment_reminder_sent', 'wpinv_payment_reminder_sent', 10, 2 ); |
|
| 1707 | +add_action('wpinv_payment_reminder_sent', 'wpinv_payment_reminder_sent', 10, 2); |
|
| 1708 | 1708 | |
| 1709 | -function wpinv_invoice_notification_set_locale( $invoice, $email_type, $site = false ) { |
|
| 1710 | - if ( empty( $invoice ) ) { |
|
| 1709 | +function wpinv_invoice_notification_set_locale($invoice, $email_type, $site = false) { |
|
| 1710 | + if (empty($invoice)) { |
|
| 1711 | 1711 | return; |
| 1712 | 1712 | } |
| 1713 | 1713 | |
| 1714 | - if ( is_int( $invoice ) ) { |
|
| 1715 | - $invoice = wpinv_get_invoice( $invoice ); |
|
| 1714 | + if (is_int($invoice)) { |
|
| 1715 | + $invoice = wpinv_get_invoice($invoice); |
|
| 1716 | 1716 | } |
| 1717 | 1717 | |
| 1718 | - if ( ! empty( $invoice ) && is_object( $invoice ) ) { |
|
| 1719 | - if ( ! $site && function_exists( 'get_user_locale' ) ) { |
|
| 1720 | - $locale = get_user_locale( $invoice->get_user_id() ); |
|
| 1718 | + if (!empty($invoice) && is_object($invoice)) { |
|
| 1719 | + if (!$site && function_exists('get_user_locale')) { |
|
| 1720 | + $locale = get_user_locale($invoice->get_user_id()); |
|
| 1721 | 1721 | } else { |
| 1722 | 1722 | $locale = get_locale(); |
| 1723 | 1723 | } |
| 1724 | 1724 | |
| 1725 | - wpinv_switch_to_locale( $locale ); |
|
| 1725 | + wpinv_switch_to_locale($locale); |
|
| 1726 | 1726 | } |
| 1727 | 1727 | } |
| 1728 | -add_action( 'wpinv_pre_send_invoice_notification', 'wpinv_invoice_notification_set_locale', 10, 3 ); |
|
| 1728 | +add_action('wpinv_pre_send_invoice_notification', 'wpinv_invoice_notification_set_locale', 10, 3); |
|
| 1729 | 1729 | |
| 1730 | -function wpinv_invoice_notification_restore_locale( $invoice, $email_type, $site = false ) { |
|
| 1731 | - if ( empty( $invoice ) ) { |
|
| 1730 | +function wpinv_invoice_notification_restore_locale($invoice, $email_type, $site = false) { |
|
| 1731 | + if (empty($invoice)) { |
|
| 1732 | 1732 | return; |
| 1733 | 1733 | } |
| 1734 | 1734 | |
| 1735 | 1735 | wpinv_restore_locale(); |
| 1736 | 1736 | } |
| 1737 | -add_action( 'wpinv_post_send_invoice_notification', 'wpinv_invoice_notification_restore_locale', 10, 3 ); |
|
| 1737 | +add_action('wpinv_post_send_invoice_notification', 'wpinv_invoice_notification_restore_locale', 10, 3); |
|
@@ -7,202 +7,202 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // MUST have WordPress. |
| 10 | -if ( !defined( 'WPINC' ) ) { |
|
| 11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 10 | +if (!defined('WPINC')) { |
|
| 11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | function wpinv_is_checkout() { |
| 15 | 15 | global $wp_query; |
| 16 | 16 | |
| 17 | - $is_object_set = isset( $wp_query->queried_object ); |
|
| 18 | - $is_object_id_set = isset( $wp_query->queried_object_id ); |
|
| 19 | - $is_checkout = is_page( wpinv_get_option( 'checkout_page' ) ); |
|
| 17 | + $is_object_set = isset($wp_query->queried_object); |
|
| 18 | + $is_object_id_set = isset($wp_query->queried_object_id); |
|
| 19 | + $is_checkout = is_page(wpinv_get_option('checkout_page')); |
|
| 20 | 20 | |
| 21 | - if ( !$is_object_set ) { |
|
| 22 | - unset( $wp_query->queried_object ); |
|
| 21 | + if (!$is_object_set) { |
|
| 22 | + unset($wp_query->queried_object); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - if ( !$is_object_id_set ) { |
|
| 26 | - unset( $wp_query->queried_object_id ); |
|
| 25 | + if (!$is_object_id_set) { |
|
| 26 | + unset($wp_query->queried_object_id); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - return apply_filters( 'wpinv_is_checkout', $is_checkout ); |
|
| 29 | + return apply_filters('wpinv_is_checkout', $is_checkout); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | function wpinv_can_checkout() { |
| 33 | 33 | $can_checkout = true; // Always true for now |
| 34 | 34 | |
| 35 | - return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
| 35 | + return (bool) apply_filters('wpinv_can_checkout', $can_checkout); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | function wpinv_get_success_page_uri() { |
| 39 | - $page_id = wpinv_get_option( 'success_page', 0 ); |
|
| 40 | - $page_id = absint( $page_id ); |
|
| 39 | + $page_id = wpinv_get_option('success_page', 0); |
|
| 40 | + $page_id = absint($page_id); |
|
| 41 | 41 | |
| 42 | - return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
| 42 | + return apply_filters('wpinv_get_success_page_uri', get_permalink($page_id)); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | function wpinv_get_history_page_uri() { |
| 46 | - $page_id = wpinv_get_option( 'invoice_history_page', 0 ); |
|
| 47 | - $page_id = absint( $page_id ); |
|
| 46 | + $page_id = wpinv_get_option('invoice_history_page', 0); |
|
| 47 | + $page_id = absint($page_id); |
|
| 48 | 48 | |
| 49 | - return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) ); |
|
| 49 | + return apply_filters('wpinv_get_history_page_uri', get_permalink($page_id)); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | function wpinv_is_success_page() { |
| 53 | - $is_success_page = wpinv_get_option( 'success_page', false ); |
|
| 54 | - $is_success_page = isset( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
| 53 | + $is_success_page = wpinv_get_option('success_page', false); |
|
| 54 | + $is_success_page = isset($is_success_page) ? is_page($is_success_page) : false; |
|
| 55 | 55 | |
| 56 | - return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
| 56 | + return apply_filters('wpinv_is_success_page', $is_success_page); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | function wpinv_is_invoice_history_page() { |
| 60 | - $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
| 61 | - $ret = $ret ? is_page( $ret ) : false; |
|
| 62 | - return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
| 60 | + $ret = wpinv_get_option('invoice_history_page', false); |
|
| 61 | + $ret = $ret ? is_page($ret) : false; |
|
| 62 | + return apply_filters('wpinv_is_invoice_history_page', $ret); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | function wpinv_is_subscriptions_history_page() { |
| 66 | - $ret = wpinv_get_option( 'invoice_subscription_page', false ); |
|
| 67 | - $ret = $ret ? is_page( $ret ) : false; |
|
| 68 | - return apply_filters( 'wpinv_is_subscriptions_history_page', $ret ); |
|
| 66 | + $ret = wpinv_get_option('invoice_subscription_page', false); |
|
| 67 | + $ret = $ret ? is_page($ret) : false; |
|
| 68 | + return apply_filters('wpinv_is_subscriptions_history_page', $ret); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | -function wpinv_send_to_success_page( $args = null ) { |
|
| 71 | +function wpinv_send_to_success_page($args = null) { |
|
| 72 | 72 | $redirect = wpinv_get_success_page_uri(); |
| 73 | 73 | |
| 74 | - if ( !empty( $args ) ) { |
|
| 74 | + if (!empty($args)) { |
|
| 75 | 75 | // Check for backward compatibility |
| 76 | - if ( is_string( $args ) ) |
|
| 77 | - $args = str_replace( '?', '', $args ); |
|
| 76 | + if (is_string($args)) |
|
| 77 | + $args = str_replace('?', '', $args); |
|
| 78 | 78 | |
| 79 | - $args = wp_parse_args( $args ); |
|
| 79 | + $args = wp_parse_args($args); |
|
| 80 | 80 | |
| 81 | - $redirect = add_query_arg( $args, $redirect ); |
|
| 81 | + $redirect = add_query_arg($args, $redirect); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : ''; |
|
| 84 | + $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : ''; |
|
| 85 | 85 | |
| 86 | - $redirect = apply_filters( 'wpinv_success_page_redirect', $redirect, $gateway, $args ); |
|
| 87 | - wp_redirect( $redirect ); |
|
| 86 | + $redirect = apply_filters('wpinv_success_page_redirect', $redirect, $gateway, $args); |
|
| 87 | + wp_redirect($redirect); |
|
| 88 | 88 | exit; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | -function wpinv_send_to_failed_page( $args = null ) { |
|
| 91 | +function wpinv_send_to_failed_page($args = null) { |
|
| 92 | 92 | $redirect = wpinv_get_failed_transaction_uri(); |
| 93 | 93 | |
| 94 | - if ( !empty( $args ) ) { |
|
| 94 | + if (!empty($args)) { |
|
| 95 | 95 | // Check for backward compatibility |
| 96 | - if ( is_string( $args ) ) |
|
| 97 | - $args = str_replace( '?', '', $args ); |
|
| 96 | + if (is_string($args)) |
|
| 97 | + $args = str_replace('?', '', $args); |
|
| 98 | 98 | |
| 99 | - $args = wp_parse_args( $args ); |
|
| 99 | + $args = wp_parse_args($args); |
|
| 100 | 100 | |
| 101 | - $redirect = add_query_arg( $args, $redirect ); |
|
| 101 | + $redirect = add_query_arg($args, $redirect); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : ''; |
|
| 104 | + $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : ''; |
|
| 105 | 105 | |
| 106 | - $redirect = apply_filters( 'wpinv_failed_page_redirect', $redirect, $gateway, $args ); |
|
| 107 | - wp_redirect( $redirect ); |
|
| 106 | + $redirect = apply_filters('wpinv_failed_page_redirect', $redirect, $gateway, $args); |
|
| 107 | + wp_redirect($redirect); |
|
| 108 | 108 | exit; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | -function wpinv_get_checkout_uri( $args = array() ) { |
|
| 112 | - $uri = wpinv_get_option( 'checkout_page', false ); |
|
| 113 | - $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
| 111 | +function wpinv_get_checkout_uri($args = array()) { |
|
| 112 | + $uri = wpinv_get_option('checkout_page', false); |
|
| 113 | + $uri = isset($uri) ? get_permalink($uri) : NULL; |
|
| 114 | 114 | |
| 115 | - if ( !empty( $args ) ) { |
|
| 115 | + if (!empty($args)) { |
|
| 116 | 116 | // Check for backward compatibility |
| 117 | - if ( is_string( $args ) ) |
|
| 118 | - $args = str_replace( '?', '', $args ); |
|
| 117 | + if (is_string($args)) |
|
| 118 | + $args = str_replace('?', '', $args); |
|
| 119 | 119 | |
| 120 | - $args = wp_parse_args( $args ); |
|
| 120 | + $args = wp_parse_args($args); |
|
| 121 | 121 | |
| 122 | - $uri = add_query_arg( $args, $uri ); |
|
| 122 | + $uri = add_query_arg($args, $uri); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
| 125 | + $scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
| 126 | 126 | |
| 127 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
| 127 | + $ajax_url = admin_url('admin-ajax.php', $scheme); |
|
| 128 | 128 | |
| 129 | - if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
| 130 | - $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
| 129 | + if ((!preg_match('/^https/', $uri) && preg_match('/^https/', $ajax_url)) || wpinv_is_ssl_enforced()) { |
|
| 130 | + $uri = preg_replace('/^http:/', 'https:', $uri); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
| 133 | + return apply_filters('wpinv_get_checkout_uri', $uri); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | -function wpinv_send_back_to_checkout( $args = array() ) { |
|
| 136 | +function wpinv_send_back_to_checkout($args = array()) { |
|
| 137 | 137 | $redirect = wpinv_get_checkout_uri(); |
| 138 | 138 | |
| 139 | - if ( ! empty( $args ) ) { |
|
| 139 | + if (!empty($args)) { |
|
| 140 | 140 | // Check for backward compatibility |
| 141 | - if ( is_string( $args ) ) |
|
| 142 | - $args = str_replace( '?', '', $args ); |
|
| 141 | + if (is_string($args)) |
|
| 142 | + $args = str_replace('?', '', $args); |
|
| 143 | 143 | |
| 144 | - $args = wp_parse_args( $args ); |
|
| 144 | + $args = wp_parse_args($args); |
|
| 145 | 145 | |
| 146 | - $redirect = add_query_arg( $args, $redirect ); |
|
| 146 | + $redirect = add_query_arg($args, $redirect); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - do_action( 'wpinv_pre_send_back_to_checkout', $args ); |
|
| 150 | - wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) ); |
|
| 149 | + do_action('wpinv_pre_send_back_to_checkout', $args); |
|
| 150 | + wp_redirect(apply_filters('wpinv_send_back_to_checkout', $redirect, $args)); |
|
| 151 | 151 | exit; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | -function wpinv_get_success_page_url( $query_string = null ) { |
|
| 155 | - $success_page = wpinv_get_option( 'success_page', 0 ); |
|
| 156 | - $success_page = get_permalink( $success_page ); |
|
| 154 | +function wpinv_get_success_page_url($query_string = null) { |
|
| 155 | + $success_page = wpinv_get_option('success_page', 0); |
|
| 156 | + $success_page = get_permalink($success_page); |
|
| 157 | 157 | |
| 158 | - if ( $query_string ) |
|
| 158 | + if ($query_string) |
|
| 159 | 159 | $success_page .= $query_string; |
| 160 | 160 | |
| 161 | - return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
| 161 | + return apply_filters('wpinv_success_page_url', $success_page); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | -function wpinv_get_failed_transaction_uri( $extras = false ) { |
|
| 165 | - $uri = wpinv_get_option( 'failure_page', '' ); |
|
| 166 | - $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
| 164 | +function wpinv_get_failed_transaction_uri($extras = false) { |
|
| 165 | + $uri = wpinv_get_option('failure_page', ''); |
|
| 166 | + $uri = !empty($uri) ? trailingslashit(get_permalink($uri)) : home_url(); |
|
| 167 | 167 | |
| 168 | - if ( $extras ) |
|
| 168 | + if ($extras) |
|
| 169 | 169 | $uri .= $extras; |
| 170 | 170 | |
| 171 | - return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
| 171 | + return apply_filters('wpinv_get_failed_transaction_uri', $uri); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | function wpinv_is_failed_transaction_page() { |
| 175 | - $ret = wpinv_get_option( 'failure_page', false ); |
|
| 176 | - $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
| 175 | + $ret = wpinv_get_option('failure_page', false); |
|
| 176 | + $ret = isset($ret) ? is_page($ret) : false; |
|
| 177 | 177 | |
| 178 | - return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
| 178 | + return apply_filters('wpinv_is_failure_page', $ret); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | -function wpinv_transaction_query( $type = 'start' ) { |
|
| 181 | +function wpinv_transaction_query($type = 'start') { |
|
| 182 | 182 | global $wpdb; |
| 183 | 183 | |
| 184 | 184 | $wpdb->hide_errors(); |
| 185 | 185 | |
| 186 | - if ( ! defined( 'WPINV_USE_TRANSACTIONS' ) ) { |
|
| 187 | - define( 'WPINV_USE_TRANSACTIONS', true ); |
|
| 186 | + if (!defined('WPINV_USE_TRANSACTIONS')) { |
|
| 187 | + define('WPINV_USE_TRANSACTIONS', true); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - if ( WPINV_USE_TRANSACTIONS ) { |
|
| 191 | - switch ( $type ) { |
|
| 190 | + if (WPINV_USE_TRANSACTIONS) { |
|
| 191 | + switch ($type) { |
|
| 192 | 192 | case 'commit' : |
| 193 | - $wpdb->query( 'COMMIT' ); |
|
| 193 | + $wpdb->query('COMMIT'); |
|
| 194 | 194 | break; |
| 195 | 195 | case 'rollback' : |
| 196 | - $wpdb->query( 'ROLLBACK' ); |
|
| 196 | + $wpdb->query('ROLLBACK'); |
|
| 197 | 197 | break; |
| 198 | 198 | default : |
| 199 | - $wpdb->query( 'START TRANSACTION' ); |
|
| 199 | + $wpdb->query('START TRANSACTION'); |
|
| 200 | 200 | break; |
| 201 | 201 | } |
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | -function wpinv_create_invoice( $args = array(), $data = array(), $wp_error = false ) { |
|
| 205 | +function wpinv_create_invoice($args = array(), $data = array(), $wp_error = false) { |
|
| 206 | 206 | $default_args = array( |
| 207 | 207 | 'status' => '', |
| 208 | 208 | 'user_id' => null, |
@@ -213,66 +213,66 @@ discard block |
||
| 213 | 213 | 'post_type' => 'wpi_invoice' |
| 214 | 214 | ); |
| 215 | 215 | |
| 216 | - $args = wp_parse_args( $args, $default_args ); |
|
| 216 | + $args = wp_parse_args($args, $default_args); |
|
| 217 | 217 | $invoice_data = array(); |
| 218 | 218 | |
| 219 | - if ( $args['invoice_id'] > 0 ) { |
|
| 220 | - $updating = true; |
|
| 219 | + if ($args['invoice_id'] > 0) { |
|
| 220 | + $updating = true; |
|
| 221 | 221 | $invoice_data['post_type'] = $args['post_type']; |
| 222 | 222 | $invoice_data['ID'] = $args['invoice_id']; |
| 223 | 223 | } else { |
| 224 | 224 | $updating = false; |
| 225 | 225 | $invoice_data['post_type'] = $args['post_type']; |
| 226 | - $invoice_data['post_status'] = apply_filters( 'wpinv_default_invoice_status', 'wpi-pending' ); |
|
| 226 | + $invoice_data['post_status'] = apply_filters('wpinv_default_invoice_status', 'wpi-pending'); |
|
| 227 | 227 | $invoice_data['ping_status'] = 'closed'; |
| 228 | - $invoice_data['post_author'] = !empty( $args['user_id'] ) ? $args['user_id'] : get_current_user_id(); |
|
| 229 | - $invoice_data['post_title'] = wpinv_format_invoice_number( '0' ); |
|
| 230 | - $invoice_data['post_parent'] = absint( $args['parent'] ); |
|
| 231 | - if ( !empty( $args['created_date'] ) ) { |
|
| 228 | + $invoice_data['post_author'] = !empty($args['user_id']) ? $args['user_id'] : get_current_user_id(); |
|
| 229 | + $invoice_data['post_title'] = wpinv_format_invoice_number('0'); |
|
| 230 | + $invoice_data['post_parent'] = absint($args['parent']); |
|
| 231 | + if (!empty($args['created_date'])) { |
|
| 232 | 232 | $invoice_data['post_date'] = $args['created_date']; |
| 233 | - $invoice_data['post_date_gmt'] = get_gmt_from_date( $args['created_date'] ); |
|
| 233 | + $invoice_data['post_date_gmt'] = get_gmt_from_date($args['created_date']); |
|
| 234 | 234 | } |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - if ( $args['status'] ) { |
|
| 238 | - if ( ! in_array( $args['status'], array_keys( wpinv_get_invoice_statuses() ) ) && 'wpi_invoice' === $invoice_data['post_type'] ) { |
|
| 239 | - return new WP_Error( 'wpinv_invalid_invoice_status', wp_sprintf( __( 'Invalid invoice status: %s', 'invoicing' ), $args['status'] ) ); |
|
| 237 | + if ($args['status']) { |
|
| 238 | + if (!in_array($args['status'], array_keys(wpinv_get_invoice_statuses())) && 'wpi_invoice' === $invoice_data['post_type']) { |
|
| 239 | + return new WP_Error('wpinv_invalid_invoice_status', wp_sprintf(__('Invalid invoice status: %s', 'invoicing'), $args['status'])); |
|
| 240 | 240 | } |
| 241 | - $invoice_data['post_status'] = $args['status']; |
|
| 241 | + $invoice_data['post_status'] = $args['status']; |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | - if ( ! is_null( $args['user_note'] ) ) { |
|
| 245 | - $invoice_data['post_excerpt'] = $args['user_note']; |
|
| 244 | + if (!is_null($args['user_note'])) { |
|
| 245 | + $invoice_data['post_excerpt'] = $args['user_note']; |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - if ( $updating ) { |
|
| 249 | - $invoice_id = wp_update_post( $invoice_data, true ); |
|
| 248 | + if ($updating) { |
|
| 249 | + $invoice_id = wp_update_post($invoice_data, true); |
|
| 250 | 250 | } else { |
| 251 | - $invoice_id = wp_insert_post( apply_filters( 'wpinv_new_invoice_data', $invoice_data ), true ); |
|
| 251 | + $invoice_id = wp_insert_post(apply_filters('wpinv_new_invoice_data', $invoice_data), true); |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | - if ( is_wp_error( $invoice_id ) ) { |
|
| 254 | + if (is_wp_error($invoice_id)) { |
|
| 255 | 255 | return $wp_error ? $invoice_id : 0; |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 259 | - |
|
| 260 | - if ( !$updating ) { |
|
| 261 | - update_post_meta( $invoice_id, '_wpinv_key', apply_filters( 'wpinv_generate_invoice_key', uniqid( 'wpinv_' ) ) ); |
|
| 262 | - update_post_meta( $invoice_id, '_wpinv_currency', wpinv_get_currency() ); |
|
| 263 | - update_post_meta( $invoice_id, '_wpinv_include_tax', get_option( 'wpinv_prices_include_tax' ) ); |
|
| 264 | - update_post_meta( $invoice_id, '_wpinv_user_ip', wpinv_get_ip() ); |
|
| 265 | - update_post_meta( $invoice_id, '_wpinv_user_agent', wpinv_get_user_agent() ); |
|
| 266 | - update_post_meta( $invoice_id, '_wpinv_created_via', sanitize_text_field( $args['created_via'] ) ); |
|
| 258 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 259 | + |
|
| 260 | + if (!$updating) { |
|
| 261 | + update_post_meta($invoice_id, '_wpinv_key', apply_filters('wpinv_generate_invoice_key', uniqid('wpinv_'))); |
|
| 262 | + update_post_meta($invoice_id, '_wpinv_currency', wpinv_get_currency()); |
|
| 263 | + update_post_meta($invoice_id, '_wpinv_include_tax', get_option('wpinv_prices_include_tax')); |
|
| 264 | + update_post_meta($invoice_id, '_wpinv_user_ip', wpinv_get_ip()); |
|
| 265 | + update_post_meta($invoice_id, '_wpinv_user_agent', wpinv_get_user_agent()); |
|
| 266 | + update_post_meta($invoice_id, '_wpinv_created_via', sanitize_text_field($args['created_via'])); |
|
| 267 | 267 | |
| 268 | 268 | // Add invoice note |
| 269 | - if ( ! $invoice->is_quote() ) { |
|
| 270 | - $invoice->add_note( wp_sprintf( __( 'Invoice is created with status %s.', 'invoicing' ), wpinv_status_nicename( $invoice->status ) ) ); |
|
| 269 | + if (!$invoice->is_quote()) { |
|
| 270 | + $invoice->add_note(wp_sprintf(__('Invoice is created with status %s.', 'invoicing'), wpinv_status_nicename($invoice->status))); |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - update_post_meta( $invoice_id, '_wpinv_version', WPINV_VERSION ); |
|
| 275 | + update_post_meta($invoice_id, '_wpinv_version', WPINV_VERSION); |
|
| 276 | 276 | |
| 277 | 277 | return $invoice; |
| 278 | 278 | } |
@@ -280,193 +280,193 @@ discard block |
||
| 280 | 280 | function wpinv_get_prefix() { |
| 281 | 281 | $invoice_prefix = 'INV-'; |
| 282 | 282 | |
| 283 | - return apply_filters( 'wpinv_get_prefix', $invoice_prefix ); |
|
| 283 | + return apply_filters('wpinv_get_prefix', $invoice_prefix); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | function wpinv_get_business_logo() { |
| 287 | - $business_logo = wpinv_get_option( 'logo' ); |
|
| 288 | - return apply_filters( 'wpinv_get_business_logo', $business_logo ); |
|
| 287 | + $business_logo = wpinv_get_option('logo'); |
|
| 288 | + return apply_filters('wpinv_get_business_logo', $business_logo); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | function wpinv_get_business_name() { |
| 292 | 292 | $business_name = wpinv_get_option('store_name'); |
| 293 | - return apply_filters( 'wpinv_get_business_name', $business_name ); |
|
| 293 | + return apply_filters('wpinv_get_business_name', $business_name); |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | function wpinv_get_blogname() { |
| 297 | - return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
|
| 297 | + return wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | function wpinv_get_admin_email() { |
| 301 | - $admin_email = wpinv_get_option( 'admin_email', get_option( 'admin_email' ) ); |
|
| 302 | - return apply_filters( 'wpinv_admin_email', $admin_email ); |
|
| 301 | + $admin_email = wpinv_get_option('admin_email', get_option('admin_email')); |
|
| 302 | + return apply_filters('wpinv_admin_email', $admin_email); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | function wpinv_get_business_website() { |
| 306 | - $business_website = home_url( '/' ); |
|
| 307 | - return apply_filters( 'wpinv_get_business_website', $business_website ); |
|
| 306 | + $business_website = home_url('/'); |
|
| 307 | + return apply_filters('wpinv_get_business_website', $business_website); |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | -function wpinv_get_terms_text( $invoice_id = 0 ) { |
|
| 310 | +function wpinv_get_terms_text($invoice_id = 0) { |
|
| 311 | 311 | $terms_text = ''; |
| 312 | - return apply_filters( 'wpinv_get_terms_text', $terms_text, $invoice_id ); |
|
| 312 | + return apply_filters('wpinv_get_terms_text', $terms_text, $invoice_id); |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | function wpinv_get_business_footer() { |
| 316 | - $site_link = '<a target="_blank" href="' . esc_url( wpinv_get_business_website() ) . '">' . esc_html( wpinv_get_business_name() ) . '</a>'; |
|
| 317 | - $business_footer = wp_sprintf( __( 'Thanks for using %s', 'invoicing' ), $site_link ); |
|
| 318 | - return apply_filters( 'wpinv_get_business_footer', $business_footer ); |
|
| 316 | + $site_link = '<a target="_blank" href="' . esc_url(wpinv_get_business_website()) . '">' . esc_html(wpinv_get_business_name()) . '</a>'; |
|
| 317 | + $business_footer = wp_sprintf(__('Thanks for using %s', 'invoicing'), $site_link); |
|
| 318 | + return apply_filters('wpinv_get_business_footer', $business_footer); |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | function wpinv_checkout_required_fields() { |
| 322 | 322 | $required_fields = array(); |
| 323 | 323 | |
| 324 | 324 | // Let payment gateways and other extensions determine if address fields should be required |
| 325 | - $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() ); |
|
| 325 | + $require_billing_details = apply_filters('wpinv_checkout_required_billing_details', wpinv_use_taxes()); |
|
| 326 | 326 | |
| 327 | - if ( $require_billing_details ) { |
|
| 328 | - if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) { |
|
| 327 | + if ($require_billing_details) { |
|
| 328 | + if ((bool) wpinv_get_option('fname_mandatory')) { |
|
| 329 | 329 | $required_fields['first_name'] = array( |
| 330 | 330 | 'error_id' => 'invalid_first_name', |
| 331 | - 'error_message' => __( 'Please enter your first name', 'invoicing' ) |
|
| 331 | + 'error_message' => __('Please enter your first name', 'invoicing') |
|
| 332 | 332 | ); |
| 333 | 333 | } |
| 334 | - if ( (bool)wpinv_get_option( 'address_mandatory' ) ) { |
|
| 334 | + if ((bool) wpinv_get_option('address_mandatory')) { |
|
| 335 | 335 | $required_fields['address'] = array( |
| 336 | 336 | 'error_id' => 'invalid_address', |
| 337 | - 'error_message' => __( 'Please enter your address', 'invoicing' ) |
|
| 337 | + 'error_message' => __('Please enter your address', 'invoicing') |
|
| 338 | 338 | ); |
| 339 | 339 | } |
| 340 | - if ( (bool)wpinv_get_option( 'city_mandatory' ) ) { |
|
| 340 | + if ((bool) wpinv_get_option('city_mandatory')) { |
|
| 341 | 341 | $required_fields['city'] = array( |
| 342 | 342 | 'error_id' => 'invalid_city', |
| 343 | - 'error_message' => __( 'Please enter your billing city', 'invoicing' ) |
|
| 343 | + 'error_message' => __('Please enter your billing city', 'invoicing') |
|
| 344 | 344 | ); |
| 345 | 345 | } |
| 346 | - if ( (bool)wpinv_get_option( 'state_mandatory' ) ) { |
|
| 346 | + if ((bool) wpinv_get_option('state_mandatory')) { |
|
| 347 | 347 | $required_fields['state'] = array( |
| 348 | 348 | 'error_id' => 'invalid_state', |
| 349 | - 'error_message' => __( 'Please enter billing state / province', 'invoicing' ) |
|
| 349 | + 'error_message' => __('Please enter billing state / province', 'invoicing') |
|
| 350 | 350 | ); |
| 351 | 351 | } |
| 352 | - if ( (bool)wpinv_get_option( 'country_mandatory' ) ) { |
|
| 352 | + if ((bool) wpinv_get_option('country_mandatory')) { |
|
| 353 | 353 | $required_fields['country'] = array( |
| 354 | 354 | 'error_id' => 'invalid_country', |
| 355 | - 'error_message' => __( 'Please select your billing country', 'invoicing' ) |
|
| 355 | + 'error_message' => __('Please select your billing country', 'invoicing') |
|
| 356 | 356 | ); |
| 357 | 357 | } |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | - return apply_filters( 'wpinv_checkout_required_fields', $required_fields ); |
|
| 360 | + return apply_filters('wpinv_checkout_required_fields', $required_fields); |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | function wpinv_is_ssl_enforced() { |
| 364 | - $ssl_enforced = wpinv_get_option( 'enforce_ssl', false ); |
|
| 365 | - return (bool) apply_filters( 'wpinv_is_ssl_enforced', $ssl_enforced ); |
|
| 364 | + $ssl_enforced = wpinv_get_option('enforce_ssl', false); |
|
| 365 | + return (bool) apply_filters('wpinv_is_ssl_enforced', $ssl_enforced); |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | -function wpinv_user_can_view_invoice( $post ) { |
|
| 368 | +function wpinv_user_can_view_invoice($post) { |
|
| 369 | 369 | $allow = false; |
| 370 | 370 | |
| 371 | - $post = get_post( $post ); |
|
| 371 | + $post = get_post($post); |
|
| 372 | 372 | |
| 373 | - if ( empty( $post->ID ) ) { |
|
| 373 | + if (empty($post->ID)) { |
|
| 374 | 374 | return $allow; |
| 375 | 375 | } |
| 376 | 376 | |
| 377 | - $invoice = wpinv_get_invoice( $post->ID ); |
|
| 378 | - if ( empty( $invoice->ID ) ) { |
|
| 377 | + $invoice = wpinv_get_invoice($post->ID); |
|
| 378 | + if (empty($invoice->ID)) { |
|
| 379 | 379 | return $allow; |
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | // Don't allow trash, draft status |
| 383 | - if ( $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) { |
|
| 384 | - if ( wpinv_current_user_can_manage_invoicing() || current_user_can( 'view_invoices', $invoice->ID ) ) { // Admin user |
|
| 383 | + if ($invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) { |
|
| 384 | + if (wpinv_current_user_can_manage_invoicing() || current_user_can('view_invoices', $invoice->ID)) { // Admin user |
|
| 385 | 385 | $allow = true; |
| 386 | 386 | } else { |
| 387 | - if ( is_user_logged_in() ) { |
|
| 388 | - if ( (int)$invoice->get_user_id() === (int)get_current_user_id() ) { |
|
| 387 | + if (is_user_logged_in()) { |
|
| 388 | + if ((int) $invoice->get_user_id() === (int) get_current_user_id()) { |
|
| 389 | 389 | $allow = true; |
| 390 | - } else if ( !wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
| 390 | + } else if (!wpinv_require_login_to_checkout() && isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
| 391 | 391 | $allow = true; |
| 392 | 392 | } |
| 393 | 393 | } else { |
| 394 | - if ( !wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
| 394 | + if (!wpinv_require_login_to_checkout() && isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
| 395 | 395 | $allow = true; |
| 396 | 396 | } |
| 397 | 397 | } |
| 398 | 398 | } |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | - return apply_filters( 'wpinv_can_print_invoice', $allow, $post, $invoice ); |
|
| 401 | + return apply_filters('wpinv_can_print_invoice', $allow, $post, $invoice); |
|
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | function wpinv_schedule_events() { |
| 405 | 405 | |
| 406 | 406 | // Get the timestamp for the next event. |
| 407 | - $timestamp = wp_next_scheduled( 'wpinv_register_schedule_event_twicedaily' ); |
|
| 407 | + $timestamp = wp_next_scheduled('wpinv_register_schedule_event_twicedaily'); |
|
| 408 | 408 | |
| 409 | - if ( $timestamp ) { |
|
| 410 | - wp_unschedule_event( $timestamp, 'wpinv_register_schedule_event_twicedaily' ); |
|
| 409 | + if ($timestamp) { |
|
| 410 | + wp_unschedule_event($timestamp, 'wpinv_register_schedule_event_twicedaily'); |
|
| 411 | 411 | } |
| 412 | 412 | |
| 413 | - if ( ! wp_next_scheduled( 'wpinv_register_schedule_event_daily' ) ) { |
|
| 414 | - wp_schedule_event( current_time( 'timestamp' ), 'daily', 'wpinv_register_schedule_event_daily' ); |
|
| 413 | + if (!wp_next_scheduled('wpinv_register_schedule_event_daily')) { |
|
| 414 | + wp_schedule_event(current_time('timestamp'), 'daily', 'wpinv_register_schedule_event_daily'); |
|
| 415 | 415 | } |
| 416 | 416 | } |
| 417 | -add_action( 'wp', 'wpinv_schedule_events' ); |
|
| 417 | +add_action('wp', 'wpinv_schedule_events'); |
|
| 418 | 418 | |
| 419 | 419 | function wpinv_schedule_event_twicedaily() { |
| 420 | 420 | wpinv_email_payment_reminders(); |
| 421 | 421 | wpinv_email_renewal_reminders(); |
| 422 | 422 | } |
| 423 | -add_action( 'wpinv_register_schedule_event_daily', 'wpinv_schedule_event_twicedaily' ); |
|
| 423 | +add_action('wpinv_register_schedule_event_daily', 'wpinv_schedule_event_twicedaily'); |
|
| 424 | 424 | |
| 425 | 425 | function wpinv_require_login_to_checkout() { |
| 426 | - $return = wpinv_get_option( 'login_to_checkout', false ); |
|
| 427 | - return (bool) apply_filters( 'wpinv_require_login_to_checkout', $return ); |
|
| 426 | + $return = wpinv_get_option('login_to_checkout', false); |
|
| 427 | + return (bool) apply_filters('wpinv_require_login_to_checkout', $return); |
|
| 428 | 428 | } |
| 429 | 429 | |
| 430 | -function wpinv_sequential_number_active( $type = '' ) { |
|
| 431 | - $check = apply_filters( 'wpinv_pre_check_sequential_number_active', null, $type ); |
|
| 432 | - if ( null !== $check ) { |
|
| 430 | +function wpinv_sequential_number_active($type = '') { |
|
| 431 | + $check = apply_filters('wpinv_pre_check_sequential_number_active', null, $type); |
|
| 432 | + if (null !== $check) { |
|
| 433 | 433 | return $check; |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | - return wpinv_get_option( 'sequential_invoice_number' ); |
|
| 436 | + return wpinv_get_option('sequential_invoice_number'); |
|
| 437 | 437 | } |
| 438 | 438 | |
| 439 | -function wpinv_switch_to_locale( $locale = NULL ) { |
|
| 439 | +function wpinv_switch_to_locale($locale = NULL) { |
|
| 440 | 440 | global $invoicing, $wpi_switch_locale; |
| 441 | 441 | |
| 442 | - if ( ! empty( $invoicing ) && function_exists( 'switch_to_locale' ) ) { |
|
| 443 | - $locale = empty( $locale ) ? get_locale() : $locale; |
|
| 442 | + if (!empty($invoicing) && function_exists('switch_to_locale')) { |
|
| 443 | + $locale = empty($locale) ? get_locale() : $locale; |
|
| 444 | 444 | |
| 445 | - switch_to_locale( $locale ); |
|
| 445 | + switch_to_locale($locale); |
|
| 446 | 446 | |
| 447 | 447 | $wpi_switch_locale = $locale; |
| 448 | 448 | |
| 449 | - add_filter( 'plugin_locale', 'get_locale' ); |
|
| 449 | + add_filter('plugin_locale', 'get_locale'); |
|
| 450 | 450 | |
| 451 | 451 | $invoicing->load_textdomain(); |
| 452 | 452 | |
| 453 | - do_action( 'wpinv_switch_to_locale', $locale ); |
|
| 453 | + do_action('wpinv_switch_to_locale', $locale); |
|
| 454 | 454 | } |
| 455 | 455 | } |
| 456 | 456 | |
| 457 | 457 | function wpinv_restore_locale() { |
| 458 | 458 | global $invoicing, $wpi_switch_locale; |
| 459 | 459 | |
| 460 | - if ( ! empty( $invoicing ) && function_exists( 'restore_previous_locale' ) && $wpi_switch_locale ) { |
|
| 460 | + if (!empty($invoicing) && function_exists('restore_previous_locale') && $wpi_switch_locale) { |
|
| 461 | 461 | restore_previous_locale(); |
| 462 | 462 | |
| 463 | 463 | $wpi_switch_locale = NULL; |
| 464 | 464 | |
| 465 | - remove_filter( 'plugin_locale', 'get_locale' ); |
|
| 465 | + remove_filter('plugin_locale', 'get_locale'); |
|
| 466 | 466 | |
| 467 | 467 | $invoicing->load_textdomain(); |
| 468 | 468 | |
| 469 | - do_action( 'wpinv_restore_locale' ); |
|
| 469 | + do_action('wpinv_restore_locale'); |
|
| 470 | 470 | } |
| 471 | 471 | } |
| 472 | 472 | |
@@ -474,22 +474,22 @@ discard block |
||
| 474 | 474 | * Returns the default form's id. |
| 475 | 475 | */ |
| 476 | 476 | function wpinv_get_default_payment_form() { |
| 477 | - $form = get_option( 'wpinv_default_payment_form' ); |
|
| 477 | + $form = get_option('wpinv_default_payment_form'); |
|
| 478 | 478 | |
| 479 | - if ( empty( $form ) || 'publish' != get_post_status( $form ) ) { |
|
| 479 | + if (empty($form) || 'publish' != get_post_status($form)) { |
|
| 480 | 480 | $form = wp_insert_post( |
| 481 | 481 | array( |
| 482 | 482 | 'post_type' => 'wpi_payment_form', |
| 483 | - 'post_title' => __( 'Checkout (default)', 'invoicing' ), |
|
| 483 | + 'post_title' => __('Checkout (default)', 'invoicing'), |
|
| 484 | 484 | 'post_status' => 'publish', |
| 485 | 485 | 'meta_input' => array( |
| 486 | - 'wpinv_form_elements' => wpinv_get_data( 'default-payment-form' ), |
|
| 486 | + 'wpinv_form_elements' => wpinv_get_data('default-payment-form'), |
|
| 487 | 487 | 'wpinv_form_items' => array(), |
| 488 | 488 | ) |
| 489 | 489 | ) |
| 490 | 490 | ); |
| 491 | 491 | |
| 492 | - update_option( 'wpinv_default_payment_form', $form ); |
|
| 492 | + update_option('wpinv_default_payment_form', $form); |
|
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | return $form; |
@@ -1,261 +1,261 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | - exit; |
|
| 3 | + exit; |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | if ( ! class_exists( 'WP_Super_Duper' ) ) { |
| 7 | 7 | |
| 8 | 8 | |
| 9 | - /** |
|
| 10 | - * A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress. |
|
| 11 | - * |
|
| 12 | - * Should not be called direct but extended instead. |
|
| 13 | - * |
|
| 14 | - * Class WP_Super_Duper |
|
| 15 | - * @since 1.0.16 change log moved to file change-log.txt - CHANGED |
|
| 16 | - * @ver 1.0.19 |
|
| 17 | - */ |
|
| 18 | - class WP_Super_Duper extends WP_Widget { |
|
| 19 | - |
|
| 20 | - public $version = "1.0.19"; |
|
| 21 | - public $font_awesome_icon_version = "5.11.2"; |
|
| 22 | - public $block_code; |
|
| 23 | - public $options; |
|
| 24 | - public $base_id; |
|
| 25 | - public $arguments = array(); |
|
| 26 | - public $instance = array(); |
|
| 27 | - private $class_name; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * The relative url to the current folder. |
|
| 31 | - * |
|
| 32 | - * @var string |
|
| 33 | - */ |
|
| 34 | - public $url = ''; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * Take the array options and use them to build. |
|
| 38 | - */ |
|
| 39 | - public function __construct( $options ) { |
|
| 40 | - global $sd_widgets; |
|
| 41 | - |
|
| 42 | - $sd_widgets[ $options['base_id'] ] = array( |
|
| 43 | - 'name' => $options['name'], |
|
| 44 | - 'class_name' => $options['class_name'] |
|
| 45 | - ); |
|
| 46 | - $this->base_id = $options['base_id']; |
|
| 47 | - // lets filter the options before we do anything |
|
| 48 | - $options = apply_filters( "wp_super_duper_options", $options ); |
|
| 49 | - $options = apply_filters( "wp_super_duper_options_{$this->base_id}", $options ); |
|
| 50 | - $options = $this->add_name_from_key( $options ); |
|
| 51 | - $this->options = $options; |
|
| 52 | - |
|
| 53 | - $this->base_id = $options['base_id']; |
|
| 54 | - $this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array(); |
|
| 55 | - |
|
| 56 | - // init parent |
|
| 57 | - parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] ); |
|
| 58 | - |
|
| 59 | - if ( isset( $options['class_name'] ) ) { |
|
| 60 | - // register widget |
|
| 61 | - $this->class_name = $options['class_name']; |
|
| 62 | - |
|
| 63 | - // register shortcode |
|
| 64 | - $this->register_shortcode(); |
|
| 65 | - |
|
| 66 | - // Fusion Builder (avada) support |
|
| 67 | - if ( function_exists( 'fusion_builder_map' ) ) { |
|
| 68 | - add_action( 'init', array( $this, 'register_fusion_element' ) ); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - // register block |
|
| 72 | - add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) ); |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - // add the CSS and JS we need ONCE |
|
| 76 | - global $sd_widget_scripts; |
|
| 77 | - |
|
| 78 | - if ( ! $sd_widget_scripts ) { |
|
| 79 | - wp_add_inline_script( 'admin-widgets', $this->widget_js() ); |
|
| 80 | - wp_add_inline_script( 'customize-controls', $this->widget_js() ); |
|
| 81 | - wp_add_inline_style( 'widgets', $this->widget_css() ); |
|
| 82 | - |
|
| 83 | - // maybe add elementor editor styles |
|
| 84 | - add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'elementor_editor_styles' ) ); |
|
| 85 | - |
|
| 86 | - $sd_widget_scripts = true; |
|
| 87 | - |
|
| 88 | - // add shortcode insert button once |
|
| 89 | - add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) ); |
|
| 90 | - // generatepress theme sections compatibility |
|
| 91 | - if ( function_exists( 'generate_sections_sections_metabox' ) ) { |
|
| 92 | - add_action( 'generate_sections_metabox', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 93 | - } |
|
| 94 | - if ( $this->is_preview() ) { |
|
| 95 | - add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 96 | - // this makes the insert button work for elementor |
|
| 97 | - add_action( 'elementor/editor/after_enqueue_scripts', array( |
|
| 98 | - $this, |
|
| 99 | - 'shortcode_insert_button_script' |
|
| 100 | - ) ); // for elementor |
|
| 101 | - } |
|
| 102 | - // this makes the insert button work for cornerstone |
|
| 103 | - add_action( 'wp_print_footer_scripts', array( __CLASS__, 'maybe_cornerstone_builder' ) ); |
|
| 104 | - |
|
| 105 | - add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) ); |
|
| 106 | - add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) ); |
|
| 107 | - |
|
| 108 | - // add generator text to admin head |
|
| 109 | - add_action( 'admin_head', array( $this, 'generator' ) ); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - do_action( 'wp_super_duper_widget_init', $options, $this ); |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * Add our widget CSS to elementor editor. |
|
| 117 | - */ |
|
| 118 | - public function elementor_editor_styles() { |
|
| 119 | - wp_add_inline_style( 'elementor-editor', $this->widget_css( false ) ); |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - public function register_fusion_element() { |
|
| 123 | - |
|
| 124 | - $options = $this->options; |
|
| 125 | - |
|
| 126 | - if ( $this->base_id ) { |
|
| 127 | - |
|
| 128 | - $params = $this->get_fusion_params(); |
|
| 129 | - |
|
| 130 | - $args = array( |
|
| 131 | - 'name' => $options['name'], |
|
| 132 | - 'shortcode' => $this->base_id, |
|
| 133 | - 'icon' => $options['block-icon'] ? $options['block-icon'] : 'far fa-square', |
|
| 134 | - 'allow_generator' => true, |
|
| 135 | - ); |
|
| 136 | - |
|
| 137 | - if ( ! empty( $params ) ) { |
|
| 138 | - $args['params'] = $params; |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - fusion_builder_map( $args ); |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - public function get_fusion_params() { |
|
| 147 | - $params = array(); |
|
| 148 | - $arguments = $this->get_arguments(); |
|
| 149 | - |
|
| 150 | - if ( ! empty( $arguments ) ) { |
|
| 151 | - foreach ( $arguments as $key => $val ) { |
|
| 152 | - $param = array(); |
|
| 153 | - // type |
|
| 154 | - $param['type'] = str_replace( |
|
| 155 | - array( |
|
| 156 | - "text", |
|
| 157 | - "number", |
|
| 158 | - "email", |
|
| 159 | - "color", |
|
| 160 | - "checkbox" |
|
| 161 | - ), |
|
| 162 | - array( |
|
| 163 | - "textfield", |
|
| 164 | - "textfield", |
|
| 165 | - "textfield", |
|
| 166 | - "colorpicker", |
|
| 167 | - "select", |
|
| 168 | - |
|
| 169 | - ), |
|
| 170 | - $val['type'] ); |
|
| 171 | - |
|
| 172 | - // multiselect |
|
| 173 | - if ( $val['type'] == 'multiselect' || ( ( $param['type'] == 'select' || $val['type'] == 'select' ) && ! empty( $val['multiple'] ) ) ) { |
|
| 174 | - $param['type'] = 'multiple_select'; |
|
| 175 | - $param['multiple'] = true; |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - // heading |
|
| 179 | - $param['heading'] = $val['title']; |
|
| 180 | - |
|
| 181 | - // description |
|
| 182 | - $param['description'] = isset( $val['desc'] ) ? $val['desc'] : ''; |
|
| 183 | - |
|
| 184 | - // param_name |
|
| 185 | - $param['param_name'] = $key; |
|
| 186 | - |
|
| 187 | - // Default |
|
| 188 | - $param['default'] = isset( $val['default'] ) ? $val['default'] : ''; |
|
| 189 | - |
|
| 190 | - // Group |
|
| 191 | - if ( isset( $val['group'] ) ) { |
|
| 192 | - $param['group'] = $val['group']; |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - // value |
|
| 196 | - if ( $val['type'] == 'checkbox' ) { |
|
| 197 | - if ( isset( $val['default'] ) && $val['default'] == '0' ) { |
|
| 198 | - unset( $param['default'] ); |
|
| 199 | - } |
|
| 200 | - $param['value'] = array( '' => __( "No" ), '1' => __( "Yes" ) ); |
|
| 201 | - } elseif ( $param['type'] == 'select' || $param['type'] == 'multiple_select' ) { |
|
| 202 | - $param['value'] = isset( $val['options'] ) ? $val['options'] : array(); |
|
| 203 | - } else { |
|
| 204 | - $param['value'] = isset( $val['default'] ) ? $val['default'] : ''; |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - // setup the param |
|
| 208 | - $params[] = $param; |
|
| 209 | - |
|
| 210 | - } |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - |
|
| 214 | - return $params; |
|
| 215 | - } |
|
| 216 | - |
|
| 217 | - /** |
|
| 218 | - * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder |
|
| 219 | - */ |
|
| 220 | - public static function maybe_cornerstone_builder() { |
|
| 221 | - if ( did_action( 'cornerstone_before_boot_app' ) ) { |
|
| 222 | - self::shortcode_insert_button_script(); |
|
| 223 | - } |
|
| 224 | - } |
|
| 225 | - |
|
| 226 | - /** |
|
| 227 | - * A function to ge the shortcode builder picker html. |
|
| 228 | - * |
|
| 229 | - * @param string $editor_id |
|
| 230 | - * |
|
| 231 | - * @return string |
|
| 232 | - */ |
|
| 233 | - public static function get_picker( $editor_id = '' ) { |
|
| 234 | - |
|
| 235 | - ob_start(); |
|
| 236 | - if ( isset( $_POST['editor_id'] ) ) { |
|
| 237 | - $editor_id = esc_attr( $_POST['editor_id'] ); |
|
| 238 | - } elseif ( isset( $_REQUEST['et_fb'] ) ) { |
|
| 239 | - $editor_id = 'main_content_content_vb_tiny_mce'; |
|
| 240 | - } |
|
| 241 | - |
|
| 242 | - global $sd_widgets; |
|
| 243 | - ?> |
|
| 9 | + /** |
|
| 10 | + * A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress. |
|
| 11 | + * |
|
| 12 | + * Should not be called direct but extended instead. |
|
| 13 | + * |
|
| 14 | + * Class WP_Super_Duper |
|
| 15 | + * @since 1.0.16 change log moved to file change-log.txt - CHANGED |
|
| 16 | + * @ver 1.0.19 |
|
| 17 | + */ |
|
| 18 | + class WP_Super_Duper extends WP_Widget { |
|
| 19 | + |
|
| 20 | + public $version = "1.0.19"; |
|
| 21 | + public $font_awesome_icon_version = "5.11.2"; |
|
| 22 | + public $block_code; |
|
| 23 | + public $options; |
|
| 24 | + public $base_id; |
|
| 25 | + public $arguments = array(); |
|
| 26 | + public $instance = array(); |
|
| 27 | + private $class_name; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * The relative url to the current folder. |
|
| 31 | + * |
|
| 32 | + * @var string |
|
| 33 | + */ |
|
| 34 | + public $url = ''; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * Take the array options and use them to build. |
|
| 38 | + */ |
|
| 39 | + public function __construct( $options ) { |
|
| 40 | + global $sd_widgets; |
|
| 41 | + |
|
| 42 | + $sd_widgets[ $options['base_id'] ] = array( |
|
| 43 | + 'name' => $options['name'], |
|
| 44 | + 'class_name' => $options['class_name'] |
|
| 45 | + ); |
|
| 46 | + $this->base_id = $options['base_id']; |
|
| 47 | + // lets filter the options before we do anything |
|
| 48 | + $options = apply_filters( "wp_super_duper_options", $options ); |
|
| 49 | + $options = apply_filters( "wp_super_duper_options_{$this->base_id}", $options ); |
|
| 50 | + $options = $this->add_name_from_key( $options ); |
|
| 51 | + $this->options = $options; |
|
| 52 | + |
|
| 53 | + $this->base_id = $options['base_id']; |
|
| 54 | + $this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array(); |
|
| 55 | + |
|
| 56 | + // init parent |
|
| 57 | + parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] ); |
|
| 58 | + |
|
| 59 | + if ( isset( $options['class_name'] ) ) { |
|
| 60 | + // register widget |
|
| 61 | + $this->class_name = $options['class_name']; |
|
| 62 | + |
|
| 63 | + // register shortcode |
|
| 64 | + $this->register_shortcode(); |
|
| 65 | + |
|
| 66 | + // Fusion Builder (avada) support |
|
| 67 | + if ( function_exists( 'fusion_builder_map' ) ) { |
|
| 68 | + add_action( 'init', array( $this, 'register_fusion_element' ) ); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + // register block |
|
| 72 | + add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) ); |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + // add the CSS and JS we need ONCE |
|
| 76 | + global $sd_widget_scripts; |
|
| 77 | + |
|
| 78 | + if ( ! $sd_widget_scripts ) { |
|
| 79 | + wp_add_inline_script( 'admin-widgets', $this->widget_js() ); |
|
| 80 | + wp_add_inline_script( 'customize-controls', $this->widget_js() ); |
|
| 81 | + wp_add_inline_style( 'widgets', $this->widget_css() ); |
|
| 82 | + |
|
| 83 | + // maybe add elementor editor styles |
|
| 84 | + add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'elementor_editor_styles' ) ); |
|
| 85 | + |
|
| 86 | + $sd_widget_scripts = true; |
|
| 87 | + |
|
| 88 | + // add shortcode insert button once |
|
| 89 | + add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) ); |
|
| 90 | + // generatepress theme sections compatibility |
|
| 91 | + if ( function_exists( 'generate_sections_sections_metabox' ) ) { |
|
| 92 | + add_action( 'generate_sections_metabox', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 93 | + } |
|
| 94 | + if ( $this->is_preview() ) { |
|
| 95 | + add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 96 | + // this makes the insert button work for elementor |
|
| 97 | + add_action( 'elementor/editor/after_enqueue_scripts', array( |
|
| 98 | + $this, |
|
| 99 | + 'shortcode_insert_button_script' |
|
| 100 | + ) ); // for elementor |
|
| 101 | + } |
|
| 102 | + // this makes the insert button work for cornerstone |
|
| 103 | + add_action( 'wp_print_footer_scripts', array( __CLASS__, 'maybe_cornerstone_builder' ) ); |
|
| 104 | + |
|
| 105 | + add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) ); |
|
| 106 | + add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) ); |
|
| 107 | + |
|
| 108 | + // add generator text to admin head |
|
| 109 | + add_action( 'admin_head', array( $this, 'generator' ) ); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + do_action( 'wp_super_duper_widget_init', $options, $this ); |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * Add our widget CSS to elementor editor. |
|
| 117 | + */ |
|
| 118 | + public function elementor_editor_styles() { |
|
| 119 | + wp_add_inline_style( 'elementor-editor', $this->widget_css( false ) ); |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + public function register_fusion_element() { |
|
| 123 | + |
|
| 124 | + $options = $this->options; |
|
| 125 | + |
|
| 126 | + if ( $this->base_id ) { |
|
| 127 | + |
|
| 128 | + $params = $this->get_fusion_params(); |
|
| 129 | + |
|
| 130 | + $args = array( |
|
| 131 | + 'name' => $options['name'], |
|
| 132 | + 'shortcode' => $this->base_id, |
|
| 133 | + 'icon' => $options['block-icon'] ? $options['block-icon'] : 'far fa-square', |
|
| 134 | + 'allow_generator' => true, |
|
| 135 | + ); |
|
| 136 | + |
|
| 137 | + if ( ! empty( $params ) ) { |
|
| 138 | + $args['params'] = $params; |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + fusion_builder_map( $args ); |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + public function get_fusion_params() { |
|
| 147 | + $params = array(); |
|
| 148 | + $arguments = $this->get_arguments(); |
|
| 149 | + |
|
| 150 | + if ( ! empty( $arguments ) ) { |
|
| 151 | + foreach ( $arguments as $key => $val ) { |
|
| 152 | + $param = array(); |
|
| 153 | + // type |
|
| 154 | + $param['type'] = str_replace( |
|
| 155 | + array( |
|
| 156 | + "text", |
|
| 157 | + "number", |
|
| 158 | + "email", |
|
| 159 | + "color", |
|
| 160 | + "checkbox" |
|
| 161 | + ), |
|
| 162 | + array( |
|
| 163 | + "textfield", |
|
| 164 | + "textfield", |
|
| 165 | + "textfield", |
|
| 166 | + "colorpicker", |
|
| 167 | + "select", |
|
| 168 | + |
|
| 169 | + ), |
|
| 170 | + $val['type'] ); |
|
| 171 | + |
|
| 172 | + // multiselect |
|
| 173 | + if ( $val['type'] == 'multiselect' || ( ( $param['type'] == 'select' || $val['type'] == 'select' ) && ! empty( $val['multiple'] ) ) ) { |
|
| 174 | + $param['type'] = 'multiple_select'; |
|
| 175 | + $param['multiple'] = true; |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + // heading |
|
| 179 | + $param['heading'] = $val['title']; |
|
| 180 | + |
|
| 181 | + // description |
|
| 182 | + $param['description'] = isset( $val['desc'] ) ? $val['desc'] : ''; |
|
| 183 | + |
|
| 184 | + // param_name |
|
| 185 | + $param['param_name'] = $key; |
|
| 186 | + |
|
| 187 | + // Default |
|
| 188 | + $param['default'] = isset( $val['default'] ) ? $val['default'] : ''; |
|
| 189 | + |
|
| 190 | + // Group |
|
| 191 | + if ( isset( $val['group'] ) ) { |
|
| 192 | + $param['group'] = $val['group']; |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + // value |
|
| 196 | + if ( $val['type'] == 'checkbox' ) { |
|
| 197 | + if ( isset( $val['default'] ) && $val['default'] == '0' ) { |
|
| 198 | + unset( $param['default'] ); |
|
| 199 | + } |
|
| 200 | + $param['value'] = array( '' => __( "No" ), '1' => __( "Yes" ) ); |
|
| 201 | + } elseif ( $param['type'] == 'select' || $param['type'] == 'multiple_select' ) { |
|
| 202 | + $param['value'] = isset( $val['options'] ) ? $val['options'] : array(); |
|
| 203 | + } else { |
|
| 204 | + $param['value'] = isset( $val['default'] ) ? $val['default'] : ''; |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + // setup the param |
|
| 208 | + $params[] = $param; |
|
| 209 | + |
|
| 210 | + } |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + |
|
| 214 | + return $params; |
|
| 215 | + } |
|
| 216 | + |
|
| 217 | + /** |
|
| 218 | + * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder |
|
| 219 | + */ |
|
| 220 | + public static function maybe_cornerstone_builder() { |
|
| 221 | + if ( did_action( 'cornerstone_before_boot_app' ) ) { |
|
| 222 | + self::shortcode_insert_button_script(); |
|
| 223 | + } |
|
| 224 | + } |
|
| 225 | + |
|
| 226 | + /** |
|
| 227 | + * A function to ge the shortcode builder picker html. |
|
| 228 | + * |
|
| 229 | + * @param string $editor_id |
|
| 230 | + * |
|
| 231 | + * @return string |
|
| 232 | + */ |
|
| 233 | + public static function get_picker( $editor_id = '' ) { |
|
| 234 | + |
|
| 235 | + ob_start(); |
|
| 236 | + if ( isset( $_POST['editor_id'] ) ) { |
|
| 237 | + $editor_id = esc_attr( $_POST['editor_id'] ); |
|
| 238 | + } elseif ( isset( $_REQUEST['et_fb'] ) ) { |
|
| 239 | + $editor_id = 'main_content_content_vb_tiny_mce'; |
|
| 240 | + } |
|
| 241 | + |
|
| 242 | + global $sd_widgets; |
|
| 243 | + ?> |
|
| 244 | 244 | |
| 245 | 245 | <div class="sd-shortcode-left-wrap"> |
| 246 | 246 | <?php |
| 247 | - ksort( $sd_widgets ); |
|
| 248 | - // print_r($sd_widgets);exit; |
|
| 249 | - if ( ! empty( $sd_widgets ) ) { |
|
| 250 | - echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">'; |
|
| 251 | - echo "<option>" . __( 'Select shortcode' ) . "</option>"; |
|
| 252 | - foreach ( $sd_widgets as $shortcode => $class ) { |
|
| 253 | - echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>"; |
|
| 254 | - } |
|
| 255 | - echo "</select>"; |
|
| 256 | - |
|
| 257 | - } |
|
| 258 | - ?> |
|
| 247 | + ksort( $sd_widgets ); |
|
| 248 | + // print_r($sd_widgets);exit; |
|
| 249 | + if ( ! empty( $sd_widgets ) ) { |
|
| 250 | + echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">'; |
|
| 251 | + echo "<option>" . __( 'Select shortcode' ) . "</option>"; |
|
| 252 | + foreach ( $sd_widgets as $shortcode => $class ) { |
|
| 253 | + echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>"; |
|
| 254 | + } |
|
| 255 | + echo "</select>"; |
|
| 256 | + |
|
| 257 | + } |
|
| 258 | + ?> |
|
| 259 | 259 | <div class="sd-shortcode-settings"></div> |
| 260 | 260 | |
| 261 | 261 | </div> |
@@ -266,8 +266,8 @@ discard block |
||
| 266 | 266 | <?php if ( $editor_id != '' ) { ?> |
| 267 | 267 | <button class="button sd-insert-shortcode-button" |
| 268 | 268 | onclick="sd_insert_shortcode(<?php if ( ! empty( $editor_id ) ) { |
| 269 | - echo "'" . $editor_id . "'"; |
|
| 270 | - } ?>)"><?php _e( 'Insert shortcode' ); ?></button> |
|
| 269 | + echo "'" . $editor_id . "'"; |
|
| 270 | + } ?>)"><?php _e( 'Insert shortcode' ); ?></button> |
|
| 271 | 271 | <?php } ?> |
| 272 | 272 | <button class="button" |
| 273 | 273 | onclick="sd_copy_to_clipboard()"><?php _e( 'Copy shortcode' ); ?></button> |
@@ -275,134 +275,134 @@ discard block |
||
| 275 | 275 | </div> |
| 276 | 276 | <?php |
| 277 | 277 | |
| 278 | - $html = ob_get_clean(); |
|
| 279 | - |
|
| 280 | - if ( wp_doing_ajax() ) { |
|
| 281 | - echo $html; |
|
| 282 | - $should_die = true; |
|
| 283 | - |
|
| 284 | - // some builder get the editor via ajax so we should not die on those ocasions |
|
| 285 | - $dont_die = array( |
|
| 286 | - 'parent_tag',// WP Bakery |
|
| 287 | - 'avia_request' // enfold |
|
| 288 | - ); |
|
| 289 | - |
|
| 290 | - foreach ( $dont_die as $request ) { |
|
| 291 | - if ( isset( $_REQUEST[ $request ] ) ) { |
|
| 292 | - $should_die = false; |
|
| 293 | - } |
|
| 294 | - } |
|
| 295 | - |
|
| 296 | - if ( $should_die ) { |
|
| 297 | - wp_die(); |
|
| 298 | - } |
|
| 299 | - |
|
| 300 | - } else { |
|
| 301 | - return $html; |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - return ''; |
|
| 305 | - |
|
| 306 | - } |
|
| 307 | - |
|
| 308 | - /** |
|
| 309 | - * Output the version in the admin header. |
|
| 310 | - */ |
|
| 311 | - public function generator() { |
|
| 312 | - echo '<meta name="generator" content="WP Super Duper v' . $this->version . '" />'; |
|
| 313 | - } |
|
| 314 | - |
|
| 315 | - /** |
|
| 316 | - * Get widget settings. |
|
| 317 | - * |
|
| 318 | - * @since 1.0.0 |
|
| 319 | - */ |
|
| 320 | - public static function get_widget_settings() { |
|
| 321 | - global $sd_widgets; |
|
| 322 | - |
|
| 323 | - $shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : ''; |
|
| 324 | - if ( ! $shortcode ) { |
|
| 325 | - wp_die(); |
|
| 326 | - } |
|
| 327 | - $widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : ''; |
|
| 328 | - if ( ! $widget_args ) { |
|
| 329 | - wp_die(); |
|
| 330 | - } |
|
| 331 | - $class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : ''; |
|
| 332 | - if ( ! $class_name ) { |
|
| 333 | - wp_die(); |
|
| 334 | - } |
|
| 335 | - |
|
| 336 | - // invoke an instance method |
|
| 337 | - $widget = new $class_name; |
|
| 338 | - |
|
| 339 | - ob_start(); |
|
| 340 | - $widget->form( array() ); |
|
| 341 | - $form = ob_get_clean(); |
|
| 342 | - echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>"; |
|
| 343 | - echo "<style>" . $widget->widget_css() . "</style>"; |
|
| 344 | - echo "<script>" . $widget->widget_js() . "</script>"; |
|
| 345 | - ?> |
|
| 278 | + $html = ob_get_clean(); |
|
| 279 | + |
|
| 280 | + if ( wp_doing_ajax() ) { |
|
| 281 | + echo $html; |
|
| 282 | + $should_die = true; |
|
| 283 | + |
|
| 284 | + // some builder get the editor via ajax so we should not die on those ocasions |
|
| 285 | + $dont_die = array( |
|
| 286 | + 'parent_tag',// WP Bakery |
|
| 287 | + 'avia_request' // enfold |
|
| 288 | + ); |
|
| 289 | + |
|
| 290 | + foreach ( $dont_die as $request ) { |
|
| 291 | + if ( isset( $_REQUEST[ $request ] ) ) { |
|
| 292 | + $should_die = false; |
|
| 293 | + } |
|
| 294 | + } |
|
| 295 | + |
|
| 296 | + if ( $should_die ) { |
|
| 297 | + wp_die(); |
|
| 298 | + } |
|
| 299 | + |
|
| 300 | + } else { |
|
| 301 | + return $html; |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + return ''; |
|
| 305 | + |
|
| 306 | + } |
|
| 307 | + |
|
| 308 | + /** |
|
| 309 | + * Output the version in the admin header. |
|
| 310 | + */ |
|
| 311 | + public function generator() { |
|
| 312 | + echo '<meta name="generator" content="WP Super Duper v' . $this->version . '" />'; |
|
| 313 | + } |
|
| 314 | + |
|
| 315 | + /** |
|
| 316 | + * Get widget settings. |
|
| 317 | + * |
|
| 318 | + * @since 1.0.0 |
|
| 319 | + */ |
|
| 320 | + public static function get_widget_settings() { |
|
| 321 | + global $sd_widgets; |
|
| 322 | + |
|
| 323 | + $shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : ''; |
|
| 324 | + if ( ! $shortcode ) { |
|
| 325 | + wp_die(); |
|
| 326 | + } |
|
| 327 | + $widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : ''; |
|
| 328 | + if ( ! $widget_args ) { |
|
| 329 | + wp_die(); |
|
| 330 | + } |
|
| 331 | + $class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : ''; |
|
| 332 | + if ( ! $class_name ) { |
|
| 333 | + wp_die(); |
|
| 334 | + } |
|
| 335 | + |
|
| 336 | + // invoke an instance method |
|
| 337 | + $widget = new $class_name; |
|
| 338 | + |
|
| 339 | + ob_start(); |
|
| 340 | + $widget->form( array() ); |
|
| 341 | + $form = ob_get_clean(); |
|
| 342 | + echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>"; |
|
| 343 | + echo "<style>" . $widget->widget_css() . "</style>"; |
|
| 344 | + echo "<script>" . $widget->widget_js() . "</script>"; |
|
| 345 | + ?> |
|
| 346 | 346 | <?php |
| 347 | - wp_die(); |
|
| 348 | - } |
|
| 349 | - |
|
| 350 | - /** |
|
| 351 | - * Insert shortcode builder button to classic editor (not inside Gutenberg, not needed). |
|
| 352 | - * |
|
| 353 | - * @since 1.0.0 |
|
| 354 | - * |
|
| 355 | - * @param string $editor_id Optional. Shortcode editor id. Default null. |
|
| 356 | - * @param string $insert_shortcode_function Optional. Insert shotcode function. Default null. |
|
| 357 | - */ |
|
| 358 | - public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) { |
|
| 359 | - global $sd_widgets, $shortcode_insert_button_once; |
|
| 360 | - if ( $shortcode_insert_button_once ) { |
|
| 361 | - return; |
|
| 362 | - } |
|
| 363 | - add_thickbox(); |
|
| 364 | - |
|
| 365 | - |
|
| 366 | - /** |
|
| 367 | - * Cornerstone makes us play dirty tricks :/ |
|
| 368 | - * All media_buttons are removed via JS unless they are two specific id's so we wrap our content in this ID so it is not removed. |
|
| 369 | - */ |
|
| 370 | - if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { |
|
| 371 | - echo '<span id="insert-media-button">'; |
|
| 372 | - } |
|
| 373 | - |
|
| 374 | - echo self::shortcode_button( 'this', 'true' ); |
|
| 375 | - |
|
| 376 | - // see opening note |
|
| 377 | - if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { |
|
| 378 | - echo '</span>'; // end #insert-media-button |
|
| 379 | - } |
|
| 380 | - |
|
| 381 | - // Add separate script for generatepress theme sections |
|
| 382 | - if ( function_exists( 'generate_sections_sections_metabox' ) && did_action( 'generate_sections_metabox' ) ) { |
|
| 383 | - } else { |
|
| 384 | - self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function ); |
|
| 385 | - } |
|
| 386 | - |
|
| 387 | - $shortcode_insert_button_once = true; |
|
| 388 | - } |
|
| 389 | - |
|
| 390 | - /** |
|
| 391 | - * Gets the shortcode insert button html. |
|
| 392 | - * |
|
| 393 | - * @param string $id |
|
| 394 | - * @param string $search_for_id |
|
| 395 | - * |
|
| 396 | - * @return mixed |
|
| 397 | - */ |
|
| 398 | - public static function shortcode_button( $id = '', $search_for_id = '' ) { |
|
| 399 | - ob_start(); |
|
| 400 | - ?> |
|
| 347 | + wp_die(); |
|
| 348 | + } |
|
| 349 | + |
|
| 350 | + /** |
|
| 351 | + * Insert shortcode builder button to classic editor (not inside Gutenberg, not needed). |
|
| 352 | + * |
|
| 353 | + * @since 1.0.0 |
|
| 354 | + * |
|
| 355 | + * @param string $editor_id Optional. Shortcode editor id. Default null. |
|
| 356 | + * @param string $insert_shortcode_function Optional. Insert shotcode function. Default null. |
|
| 357 | + */ |
|
| 358 | + public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) { |
|
| 359 | + global $sd_widgets, $shortcode_insert_button_once; |
|
| 360 | + if ( $shortcode_insert_button_once ) { |
|
| 361 | + return; |
|
| 362 | + } |
|
| 363 | + add_thickbox(); |
|
| 364 | + |
|
| 365 | + |
|
| 366 | + /** |
|
| 367 | + * Cornerstone makes us play dirty tricks :/ |
|
| 368 | + * All media_buttons are removed via JS unless they are two specific id's so we wrap our content in this ID so it is not removed. |
|
| 369 | + */ |
|
| 370 | + if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { |
|
| 371 | + echo '<span id="insert-media-button">'; |
|
| 372 | + } |
|
| 373 | + |
|
| 374 | + echo self::shortcode_button( 'this', 'true' ); |
|
| 375 | + |
|
| 376 | + // see opening note |
|
| 377 | + if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { |
|
| 378 | + echo '</span>'; // end #insert-media-button |
|
| 379 | + } |
|
| 380 | + |
|
| 381 | + // Add separate script for generatepress theme sections |
|
| 382 | + if ( function_exists( 'generate_sections_sections_metabox' ) && did_action( 'generate_sections_metabox' ) ) { |
|
| 383 | + } else { |
|
| 384 | + self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function ); |
|
| 385 | + } |
|
| 386 | + |
|
| 387 | + $shortcode_insert_button_once = true; |
|
| 388 | + } |
|
| 389 | + |
|
| 390 | + /** |
|
| 391 | + * Gets the shortcode insert button html. |
|
| 392 | + * |
|
| 393 | + * @param string $id |
|
| 394 | + * @param string $search_for_id |
|
| 395 | + * |
|
| 396 | + * @return mixed |
|
| 397 | + */ |
|
| 398 | + public static function shortcode_button( $id = '', $search_for_id = '' ) { |
|
| 399 | + ob_start(); |
|
| 400 | + ?> |
|
| 401 | 401 | <span class="sd-lable-shortcode-inserter"> |
| 402 | 402 | <a onclick="sd_ajax_get_picker(<?php echo $id; |
| 403 | - if ( $search_for_id ) { |
|
| 404 | - echo "," . $search_for_id; |
|
| 405 | - } ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed" |
|
| 403 | + if ( $search_for_id ) { |
|
| 404 | + echo "," . $search_for_id; |
|
| 405 | + } ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed" |
|
| 406 | 406 | class="thickbox button super-duper-content-open" title="Add Shortcode"> |
| 407 | 407 | <span style="vertical-align: middle;line-height: 18px;font-size: 20px;" |
| 408 | 408 | class="dashicons dashicons-screenoptions"></span> |
@@ -413,21 +413,21 @@ discard block |
||
| 413 | 413 | </span> |
| 414 | 414 | |
| 415 | 415 | <?php |
| 416 | - $html = ob_get_clean(); |
|
| 417 | - |
|
| 418 | - // remove line breaks so we can use it in js |
|
| 419 | - return preg_replace( "/\r|\n/", "", trim( $html ) ); |
|
| 420 | - } |
|
| 421 | - |
|
| 422 | - /** |
|
| 423 | - * Makes SD work with the siteOrigin page builder. |
|
| 424 | - * |
|
| 425 | - * @since 1.0.6 |
|
| 426 | - * @return mixed |
|
| 427 | - */ |
|
| 428 | - public static function siteorigin_js() { |
|
| 429 | - ob_start(); |
|
| 430 | - ?> |
|
| 416 | + $html = ob_get_clean(); |
|
| 417 | + |
|
| 418 | + // remove line breaks so we can use it in js |
|
| 419 | + return preg_replace( "/\r|\n/", "", trim( $html ) ); |
|
| 420 | + } |
|
| 421 | + |
|
| 422 | + /** |
|
| 423 | + * Makes SD work with the siteOrigin page builder. |
|
| 424 | + * |
|
| 425 | + * @since 1.0.6 |
|
| 426 | + * @return mixed |
|
| 427 | + */ |
|
| 428 | + public static function siteorigin_js() { |
|
| 429 | + ob_start(); |
|
| 430 | + ?> |
|
| 431 | 431 | <script> |
| 432 | 432 | /** |
| 433 | 433 | * Check a form to see what items shoudl be shown or hidden. |
@@ -505,28 +505,28 @@ discard block |
||
| 505 | 505 | }); |
| 506 | 506 | </script> |
| 507 | 507 | <?php |
| 508 | - $output = ob_get_clean(); |
|
| 508 | + $output = ob_get_clean(); |
|
| 509 | 509 | |
| 510 | - /* |
|
| 510 | + /* |
|
| 511 | 511 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 512 | 512 | */ |
| 513 | 513 | |
| 514 | - return str_replace( array( |
|
| 515 | - '<script>', |
|
| 516 | - '</script>' |
|
| 517 | - ), '', $output ); |
|
| 518 | - } |
|
| 519 | - |
|
| 520 | - /** |
|
| 521 | - * Output the JS and CSS for the shortcode insert button. |
|
| 522 | - * |
|
| 523 | - * @since 1.0.6 |
|
| 524 | - * |
|
| 525 | - * @param string $editor_id |
|
| 526 | - * @param string $insert_shortcode_function |
|
| 527 | - */ |
|
| 528 | - public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) { |
|
| 529 | - ?> |
|
| 514 | + return str_replace( array( |
|
| 515 | + '<script>', |
|
| 516 | + '</script>' |
|
| 517 | + ), '', $output ); |
|
| 518 | + } |
|
| 519 | + |
|
| 520 | + /** |
|
| 521 | + * Output the JS and CSS for the shortcode insert button. |
|
| 522 | + * |
|
| 523 | + * @since 1.0.6 |
|
| 524 | + * |
|
| 525 | + * @param string $editor_id |
|
| 526 | + * @param string $insert_shortcode_function |
|
| 527 | + */ |
|
| 528 | + public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) { |
|
| 529 | + ?> |
|
| 530 | 530 | <style> |
| 531 | 531 | .sd-shortcode-left-wrap { |
| 532 | 532 | float: left; |
@@ -652,35 +652,35 @@ discard block |
||
| 652 | 652 | <?php } ?> |
| 653 | 653 | </style> |
| 654 | 654 | <?php |
| 655 | - if ( class_exists( 'SiteOrigin_Panels' ) ) { |
|
| 656 | - echo "<script>" . self::siteorigin_js() . "</script>"; |
|
| 657 | - } |
|
| 658 | - ?> |
|
| 655 | + if ( class_exists( 'SiteOrigin_Panels' ) ) { |
|
| 656 | + echo "<script>" . self::siteorigin_js() . "</script>"; |
|
| 657 | + } |
|
| 658 | + ?> |
|
| 659 | 659 | <script> |
| 660 | 660 | <?php |
| 661 | - if(! empty( $insert_shortcode_function )){ |
|
| 662 | - echo $insert_shortcode_function; |
|
| 663 | - }else{ |
|
| 664 | - |
|
| 665 | - /** |
|
| 666 | - * Function for super duper insert shortcode. |
|
| 667 | - * |
|
| 668 | - * @since 1.0.0 |
|
| 669 | - */ |
|
| 670 | - ?> |
|
| 661 | + if(! empty( $insert_shortcode_function )){ |
|
| 662 | + echo $insert_shortcode_function; |
|
| 663 | + }else{ |
|
| 664 | + |
|
| 665 | + /** |
|
| 666 | + * Function for super duper insert shortcode. |
|
| 667 | + * |
|
| 668 | + * @since 1.0.0 |
|
| 669 | + */ |
|
| 670 | + ?> |
|
| 671 | 671 | function sd_insert_shortcode($editor_id) { |
| 672 | 672 | $shortcode = jQuery('#TB_ajaxContent #sd-shortcode-output').val(); |
| 673 | 673 | if ($shortcode) { |
| 674 | 674 | if (!$editor_id) { |
| 675 | 675 | <?php |
| 676 | - if ( isset( $_REQUEST['et_fb'] ) ) { |
|
| 677 | - echo '$editor_id = "#main_content_content_vb_tiny_mce";'; |
|
| 678 | - } elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) { |
|
| 679 | - echo '$editor_id = "#elementor-controls .wp-editor-container textarea";'; |
|
| 680 | - } else { |
|
| 681 | - echo '$editor_id = "#wp-content-editor-container textarea";'; |
|
| 682 | - } |
|
| 683 | - ?> |
|
| 676 | + if ( isset( $_REQUEST['et_fb'] ) ) { |
|
| 677 | + echo '$editor_id = "#main_content_content_vb_tiny_mce";'; |
|
| 678 | + } elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) { |
|
| 679 | + echo '$editor_id = "#elementor-controls .wp-editor-container textarea";'; |
|
| 680 | + } else { |
|
| 681 | + echo '$editor_id = "#wp-content-editor-container textarea";'; |
|
| 682 | + } |
|
| 683 | + ?> |
|
| 684 | 684 | } else { |
| 685 | 685 | $editor_id = '#' + $editor_id; |
| 686 | 686 | } |
@@ -1006,18 +1006,18 @@ discard block |
||
| 1006 | 1006 | |
| 1007 | 1007 | </script> |
| 1008 | 1008 | <?php |
| 1009 | - } |
|
| 1010 | - |
|
| 1011 | - /** |
|
| 1012 | - * Gets some CSS for the widgets screen. |
|
| 1013 | - * |
|
| 1014 | - * @param bool $advanced If we should include advanced CSS. |
|
| 1015 | - * |
|
| 1016 | - * @return mixed |
|
| 1017 | - */ |
|
| 1018 | - public function widget_css( $advanced = true ) { |
|
| 1019 | - ob_start(); |
|
| 1020 | - ?> |
|
| 1009 | + } |
|
| 1010 | + |
|
| 1011 | + /** |
|
| 1012 | + * Gets some CSS for the widgets screen. |
|
| 1013 | + * |
|
| 1014 | + * @param bool $advanced If we should include advanced CSS. |
|
| 1015 | + * |
|
| 1016 | + * @return mixed |
|
| 1017 | + */ |
|
| 1018 | + public function widget_css( $advanced = true ) { |
|
| 1019 | + ob_start(); |
|
| 1020 | + ?> |
|
| 1021 | 1021 | <style> |
| 1022 | 1022 | <?php if( $advanced ){ ?> |
| 1023 | 1023 | .sd-advanced-setting { |
@@ -1055,26 +1055,26 @@ discard block |
||
| 1055 | 1055 | } |
| 1056 | 1056 | </style> |
| 1057 | 1057 | <?php |
| 1058 | - $output = ob_get_clean(); |
|
| 1058 | + $output = ob_get_clean(); |
|
| 1059 | 1059 | |
| 1060 | - /* |
|
| 1060 | + /* |
|
| 1061 | 1061 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1062 | 1062 | */ |
| 1063 | 1063 | |
| 1064 | - return str_replace( array( |
|
| 1065 | - '<style>', |
|
| 1066 | - '</style>' |
|
| 1067 | - ), '', $output ); |
|
| 1068 | - } |
|
| 1069 | - |
|
| 1070 | - /** |
|
| 1071 | - * Gets some JS for the widgets screen. |
|
| 1072 | - * |
|
| 1073 | - * @return mixed |
|
| 1074 | - */ |
|
| 1075 | - public function widget_js() { |
|
| 1076 | - ob_start(); |
|
| 1077 | - ?> |
|
| 1064 | + return str_replace( array( |
|
| 1065 | + '<style>', |
|
| 1066 | + '</style>' |
|
| 1067 | + ), '', $output ); |
|
| 1068 | + } |
|
| 1069 | + |
|
| 1070 | + /** |
|
| 1071 | + * Gets some JS for the widgets screen. |
|
| 1072 | + * |
|
| 1073 | + * @return mixed |
|
| 1074 | + */ |
|
| 1075 | + public function widget_js() { |
|
| 1076 | + ob_start(); |
|
| 1077 | + ?> |
|
| 1078 | 1078 | <script> |
| 1079 | 1079 | |
| 1080 | 1080 | /** |
@@ -1229,401 +1229,401 @@ discard block |
||
| 1229 | 1229 | <?php do_action( 'wp_super_duper_widget_js', $this ); ?> |
| 1230 | 1230 | </script> |
| 1231 | 1231 | <?php |
| 1232 | - $output = ob_get_clean(); |
|
| 1232 | + $output = ob_get_clean(); |
|
| 1233 | 1233 | |
| 1234 | - /* |
|
| 1234 | + /* |
|
| 1235 | 1235 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1236 | 1236 | */ |
| 1237 | 1237 | |
| 1238 | - return str_replace( array( |
|
| 1239 | - '<script>', |
|
| 1240 | - '</script>' |
|
| 1241 | - ), '', $output ); |
|
| 1242 | - } |
|
| 1243 | - |
|
| 1244 | - |
|
| 1245 | - /** |
|
| 1246 | - * Set the name from the argument key. |
|
| 1247 | - * |
|
| 1248 | - * @param $options |
|
| 1249 | - * |
|
| 1250 | - * @return mixed |
|
| 1251 | - */ |
|
| 1252 | - private function add_name_from_key( $options, $arguments = false ) { |
|
| 1253 | - if ( ! empty( $options['arguments'] ) ) { |
|
| 1254 | - foreach ( $options['arguments'] as $key => $val ) { |
|
| 1255 | - $options['arguments'][ $key ]['name'] = $key; |
|
| 1256 | - } |
|
| 1257 | - } elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) { |
|
| 1258 | - foreach ( $options as $key => $val ) { |
|
| 1259 | - $options[ $key ]['name'] = $key; |
|
| 1260 | - } |
|
| 1261 | - } |
|
| 1262 | - |
|
| 1263 | - return $options; |
|
| 1264 | - } |
|
| 1265 | - |
|
| 1266 | - /** |
|
| 1267 | - * Register the parent shortcode. |
|
| 1268 | - * |
|
| 1269 | - * @since 1.0.0 |
|
| 1270 | - */ |
|
| 1271 | - public function register_shortcode() { |
|
| 1272 | - add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) ); |
|
| 1273 | - add_action( 'wp_ajax_super_duper_output_shortcode', array( __CLASS__, 'render_shortcode' ) ); |
|
| 1274 | - } |
|
| 1275 | - |
|
| 1276 | - /** |
|
| 1277 | - * Render the shortcode via ajax so we can return it to Gutenberg. |
|
| 1278 | - * |
|
| 1279 | - * @since 1.0.0 |
|
| 1280 | - */ |
|
| 1281 | - public static function render_shortcode() { |
|
| 1282 | - |
|
| 1283 | - check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true ); |
|
| 1284 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 1285 | - wp_die(); |
|
| 1286 | - } |
|
| 1287 | - |
|
| 1288 | - // we might need the $post value here so lets set it. |
|
| 1289 | - if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) { |
|
| 1290 | - $post_obj = get_post( absint( $_POST['post_id'] ) ); |
|
| 1291 | - if ( ! empty( $post_obj ) && empty( $post ) ) { |
|
| 1292 | - global $post; |
|
| 1293 | - $post = $post_obj; |
|
| 1294 | - } |
|
| 1295 | - } |
|
| 1296 | - |
|
| 1297 | - if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) { |
|
| 1298 | - $shortcode_name = sanitize_title_with_dashes( $_POST['shortcode'] ); |
|
| 1299 | - $attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array(); |
|
| 1300 | - $attributes = ''; |
|
| 1301 | - if ( ! empty( $attributes_array ) ) { |
|
| 1302 | - foreach ( $attributes_array as $key => $value ) { |
|
| 1303 | - $attributes .= " " . sanitize_title_with_dashes( $key ) . "='" . wp_slash( $value ) . "' "; |
|
| 1304 | - } |
|
| 1305 | - } |
|
| 1306 | - |
|
| 1307 | - $shortcode = "[" . $shortcode_name . " " . $attributes . "]"; |
|
| 1308 | - |
|
| 1309 | - echo do_shortcode( $shortcode ); |
|
| 1310 | - |
|
| 1311 | - } |
|
| 1312 | - wp_die(); |
|
| 1313 | - } |
|
| 1314 | - |
|
| 1315 | - /** |
|
| 1316 | - * Output the shortcode. |
|
| 1317 | - * |
|
| 1318 | - * @param array $args |
|
| 1319 | - * @param string $content |
|
| 1320 | - * |
|
| 1321 | - * @return string |
|
| 1322 | - */ |
|
| 1323 | - public function shortcode_output( $args = array(), $content = '' ) { |
|
| 1324 | - $args = self::argument_values( $args ); |
|
| 1325 | - |
|
| 1326 | - // add extra argument so we know its a output to gutenberg |
|
| 1327 | - //$args |
|
| 1328 | - $args = $this->string_to_bool( $args ); |
|
| 1329 | - |
|
| 1330 | - // if we have a enclosed shortcode we add it to the special `html` argument |
|
| 1331 | - if ( ! empty( $content ) ) { |
|
| 1332 | - $args['html'] = $content; |
|
| 1333 | - } |
|
| 1334 | - |
|
| 1335 | - $class = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : ''; |
|
| 1336 | - |
|
| 1337 | - $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this ); |
|
| 1338 | - $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this ); |
|
| 1339 | - |
|
| 1340 | - $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this ); |
|
| 1341 | - $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this ); //@todo this does not seem right @kiran? |
|
| 1342 | - |
|
| 1343 | - $shortcode_args = array(); |
|
| 1344 | - $output = ''; |
|
| 1345 | - $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false; |
|
| 1346 | - if ( isset( $args['no_wrap'] ) && $args['no_wrap'] ) { |
|
| 1347 | - $no_wrap = true; |
|
| 1348 | - } |
|
| 1349 | - $main_content = $this->output( $args, $shortcode_args, $content ); |
|
| 1350 | - if ( $main_content && ! $no_wrap ) { |
|
| 1351 | - // wrap the shortcode in a div with the same class as the widget |
|
| 1352 | - $output .= '<div class="' . $class . '" ' . $attrs . '>'; |
|
| 1353 | - if ( ! empty( $args['title'] ) ) { |
|
| 1354 | - // if its a shortcode and there is a title try to grab the title wrappers |
|
| 1355 | - $shortcode_args = array( 'before_title' => '', 'after_title' => '' ); |
|
| 1356 | - if ( empty( $instance ) ) { |
|
| 1357 | - global $wp_registered_sidebars; |
|
| 1358 | - if ( ! empty( $wp_registered_sidebars ) ) { |
|
| 1359 | - foreach ( $wp_registered_sidebars as $sidebar ) { |
|
| 1360 | - if ( ! empty( $sidebar['before_title'] ) ) { |
|
| 1361 | - $shortcode_args['before_title'] = $sidebar['before_title']; |
|
| 1362 | - $shortcode_args['after_title'] = $sidebar['after_title']; |
|
| 1363 | - break; |
|
| 1364 | - } |
|
| 1365 | - } |
|
| 1366 | - } |
|
| 1367 | - } |
|
| 1368 | - $output .= $this->output_title( $shortcode_args, $args ); |
|
| 1369 | - } |
|
| 1370 | - $output .= $main_content; |
|
| 1371 | - $output .= '</div>'; |
|
| 1372 | - } elseif ( $main_content && $no_wrap ) { |
|
| 1373 | - $output .= $main_content; |
|
| 1374 | - } |
|
| 1375 | - |
|
| 1376 | - // if preview show a placeholder if empty |
|
| 1377 | - if ( $this->is_preview() && $output == '' ) { |
|
| 1378 | - $output = $this->preview_placeholder_text( "[{" . $this->base_id . "}]" ); |
|
| 1379 | - } |
|
| 1380 | - |
|
| 1381 | - return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this ); |
|
| 1382 | - } |
|
| 1383 | - |
|
| 1384 | - /** |
|
| 1385 | - * Placeholder text to show if output is empty and we are on a preview/builder page. |
|
| 1386 | - * |
|
| 1387 | - * @param string $name |
|
| 1388 | - * |
|
| 1389 | - * @return string |
|
| 1390 | - */ |
|
| 1391 | - public function preview_placeholder_text( $name = '' ) { |
|
| 1392 | - return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf( __( 'Placeholder for: %s' ), $name ) . "</div>"; |
|
| 1393 | - } |
|
| 1394 | - |
|
| 1395 | - /** |
|
| 1396 | - * Sometimes booleans values can be turned to strings, so we fix that. |
|
| 1397 | - * |
|
| 1398 | - * @param $options |
|
| 1399 | - * |
|
| 1400 | - * @return mixed |
|
| 1401 | - */ |
|
| 1402 | - public function string_to_bool( $options ) { |
|
| 1403 | - // convert bool strings to booleans |
|
| 1404 | - foreach ( $options as $key => $val ) { |
|
| 1405 | - if ( $val == 'false' ) { |
|
| 1406 | - $options[ $key ] = false; |
|
| 1407 | - } elseif ( $val == 'true' ) { |
|
| 1408 | - $options[ $key ] = true; |
|
| 1409 | - } |
|
| 1410 | - } |
|
| 1411 | - |
|
| 1412 | - return $options; |
|
| 1413 | - } |
|
| 1414 | - |
|
| 1415 | - /** |
|
| 1416 | - * Get the argument values that are also filterable. |
|
| 1417 | - * |
|
| 1418 | - * @param $instance |
|
| 1419 | - * |
|
| 1420 | - * @since 1.0.12 Don't set checkbox default value if the value is empty. |
|
| 1421 | - * |
|
| 1422 | - * @return array |
|
| 1423 | - */ |
|
| 1424 | - public function argument_values( $instance ) { |
|
| 1425 | - $argument_values = array(); |
|
| 1426 | - |
|
| 1427 | - // set widget instance |
|
| 1428 | - $this->instance = $instance; |
|
| 1429 | - |
|
| 1430 | - if ( empty( $this->arguments ) ) { |
|
| 1431 | - $this->arguments = $this->get_arguments(); |
|
| 1432 | - } |
|
| 1433 | - |
|
| 1434 | - if ( ! empty( $this->arguments ) ) { |
|
| 1435 | - foreach ( $this->arguments as $key => $args ) { |
|
| 1436 | - // set the input name from the key |
|
| 1437 | - $args['name'] = $key; |
|
| 1438 | - // |
|
| 1439 | - $argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : ''; |
|
| 1440 | - if ( $args['type'] == 'checkbox' && $argument_values[ $key ] == '' ) { |
|
| 1441 | - // don't set default for an empty checkbox |
|
| 1442 | - } elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) { |
|
| 1443 | - $argument_values[ $key ] = $args['default']; |
|
| 1444 | - } |
|
| 1445 | - } |
|
| 1446 | - } |
|
| 1447 | - |
|
| 1448 | - return $argument_values; |
|
| 1449 | - } |
|
| 1450 | - |
|
| 1451 | - /** |
|
| 1452 | - * Set arguments in super duper. |
|
| 1453 | - * |
|
| 1454 | - * @since 1.0.0 |
|
| 1455 | - * |
|
| 1456 | - * @return array Set arguments. |
|
| 1457 | - */ |
|
| 1458 | - public function set_arguments() { |
|
| 1459 | - return $this->arguments; |
|
| 1460 | - } |
|
| 1461 | - |
|
| 1462 | - /** |
|
| 1463 | - * Get arguments in super duper. |
|
| 1464 | - * |
|
| 1465 | - * @since 1.0.0 |
|
| 1466 | - * |
|
| 1467 | - * @return array Get arguments. |
|
| 1468 | - */ |
|
| 1469 | - public function get_arguments() { |
|
| 1470 | - if ( empty( $this->arguments ) ) { |
|
| 1471 | - $this->arguments = $this->set_arguments(); |
|
| 1472 | - } |
|
| 1473 | - |
|
| 1474 | - $this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance ); |
|
| 1475 | - $this->arguments = $this->add_name_from_key( $this->arguments, true ); |
|
| 1476 | - |
|
| 1477 | - return $this->arguments; |
|
| 1478 | - } |
|
| 1479 | - |
|
| 1480 | - /** |
|
| 1481 | - * This is the main output class for all 3 items, widget, shortcode and block, it is extended in the calling class. |
|
| 1482 | - * |
|
| 1483 | - * @param array $args |
|
| 1484 | - * @param array $widget_args |
|
| 1485 | - * @param string $content |
|
| 1486 | - */ |
|
| 1487 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 1488 | - |
|
| 1489 | - } |
|
| 1490 | - |
|
| 1491 | - /** |
|
| 1492 | - * Add the dynamic block code inline when the wp-block in enqueued. |
|
| 1493 | - */ |
|
| 1494 | - public function register_block() { |
|
| 1495 | - wp_add_inline_script( 'wp-blocks', $this->block() ); |
|
| 1496 | - if ( class_exists( 'SiteOrigin_Panels' ) ) { |
|
| 1497 | - |
|
| 1498 | - wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() ); |
|
| 1499 | - |
|
| 1500 | - } |
|
| 1501 | - } |
|
| 1502 | - |
|
| 1503 | - /** |
|
| 1504 | - * Check if we need to show advanced options. |
|
| 1505 | - * |
|
| 1506 | - * @return bool |
|
| 1507 | - */ |
|
| 1508 | - public function block_show_advanced() { |
|
| 1509 | - |
|
| 1510 | - $show = false; |
|
| 1511 | - $arguments = $this->arguments; |
|
| 1512 | - |
|
| 1513 | - if ( empty( $arguments ) ) { |
|
| 1514 | - $arguments = $this->get_arguments(); |
|
| 1515 | - } |
|
| 1516 | - |
|
| 1517 | - if ( ! empty( $arguments ) ) { |
|
| 1518 | - foreach ( $arguments as $argument ) { |
|
| 1519 | - if ( isset( $argument['advanced'] ) && $argument['advanced'] ) { |
|
| 1520 | - $show = true; |
|
| 1521 | - break; // no need to continue if we know we have it |
|
| 1522 | - } |
|
| 1523 | - } |
|
| 1524 | - } |
|
| 1525 | - |
|
| 1526 | - return $show; |
|
| 1527 | - } |
|
| 1528 | - |
|
| 1529 | - /** |
|
| 1530 | - * Get the url path to the current folder. |
|
| 1531 | - * |
|
| 1532 | - * @return string |
|
| 1533 | - */ |
|
| 1534 | - public function get_url() { |
|
| 1535 | - |
|
| 1536 | - $url = $this->url; |
|
| 1537 | - |
|
| 1538 | - if ( ! $url ) { |
|
| 1539 | - // check if we are inside a plugin |
|
| 1540 | - $file_dir = str_replace( "/includes", "", dirname( __FILE__ ) ); |
|
| 1541 | - |
|
| 1542 | - $dir_parts = explode( "/wp-content/", $file_dir ); |
|
| 1543 | - $url_parts = explode( "/wp-content/", plugins_url() ); |
|
| 1544 | - |
|
| 1545 | - if ( ! empty( $url_parts[0] ) && ! empty( $dir_parts[1] ) ) { |
|
| 1546 | - $url = trailingslashit( $url_parts[0] . "/wp-content/" . $dir_parts[1] ); |
|
| 1547 | - $this->url = $url; |
|
| 1548 | - } |
|
| 1549 | - } |
|
| 1550 | - |
|
| 1551 | - |
|
| 1552 | - return $url; |
|
| 1553 | - } |
|
| 1554 | - |
|
| 1555 | - /** |
|
| 1556 | - * Generate the block icon. |
|
| 1557 | - * |
|
| 1558 | - * Enables the use of Font Awesome icons. |
|
| 1559 | - * |
|
| 1560 | - * @note xlink:href is actually deprecated but href is not supported by all so we use both. |
|
| 1561 | - * |
|
| 1562 | - * @param $icon |
|
| 1563 | - * |
|
| 1564 | - * @since 1.1.0 |
|
| 1565 | - * @return string |
|
| 1566 | - */ |
|
| 1567 | - public function get_block_icon( $icon ) { |
|
| 1568 | - |
|
| 1569 | - // check if we have a Font Awesome icon |
|
| 1570 | - $fa_type = ''; |
|
| 1571 | - if ( substr( $icon, 0, 7 ) === "fas fa-" ) { |
|
| 1572 | - $fa_type = 'solid'; |
|
| 1573 | - } elseif ( substr( $icon, 0, 7 ) === "far fa-" ) { |
|
| 1574 | - $fa_type = 'regular'; |
|
| 1575 | - } elseif ( substr( $icon, 0, 7 ) === "fab fa-" ) { |
|
| 1576 | - $fa_type = 'brands'; |
|
| 1577 | - } else { |
|
| 1578 | - $icon = "'" . $icon . "'"; |
|
| 1579 | - } |
|
| 1580 | - |
|
| 1581 | - // set the icon if we found one |
|
| 1582 | - if ( $fa_type ) { |
|
| 1583 | - $fa_icon = str_replace( array( "fas fa-", "far fa-", "fab fa-" ), "", $icon ); |
|
| 1584 | - $icon = "el('svg',{width: 20, height: 20, viewBox: '0 0 20 20'},el('use', {'xlink:href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "','href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "'}))"; |
|
| 1585 | - } |
|
| 1586 | - |
|
| 1587 | - return $icon; |
|
| 1588 | - } |
|
| 1589 | - |
|
| 1590 | - public function group_arguments( $arguments ) { |
|
| 1238 | + return str_replace( array( |
|
| 1239 | + '<script>', |
|
| 1240 | + '</script>' |
|
| 1241 | + ), '', $output ); |
|
| 1242 | + } |
|
| 1243 | + |
|
| 1244 | + |
|
| 1245 | + /** |
|
| 1246 | + * Set the name from the argument key. |
|
| 1247 | + * |
|
| 1248 | + * @param $options |
|
| 1249 | + * |
|
| 1250 | + * @return mixed |
|
| 1251 | + */ |
|
| 1252 | + private function add_name_from_key( $options, $arguments = false ) { |
|
| 1253 | + if ( ! empty( $options['arguments'] ) ) { |
|
| 1254 | + foreach ( $options['arguments'] as $key => $val ) { |
|
| 1255 | + $options['arguments'][ $key ]['name'] = $key; |
|
| 1256 | + } |
|
| 1257 | + } elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) { |
|
| 1258 | + foreach ( $options as $key => $val ) { |
|
| 1259 | + $options[ $key ]['name'] = $key; |
|
| 1260 | + } |
|
| 1261 | + } |
|
| 1262 | + |
|
| 1263 | + return $options; |
|
| 1264 | + } |
|
| 1265 | + |
|
| 1266 | + /** |
|
| 1267 | + * Register the parent shortcode. |
|
| 1268 | + * |
|
| 1269 | + * @since 1.0.0 |
|
| 1270 | + */ |
|
| 1271 | + public function register_shortcode() { |
|
| 1272 | + add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) ); |
|
| 1273 | + add_action( 'wp_ajax_super_duper_output_shortcode', array( __CLASS__, 'render_shortcode' ) ); |
|
| 1274 | + } |
|
| 1275 | + |
|
| 1276 | + /** |
|
| 1277 | + * Render the shortcode via ajax so we can return it to Gutenberg. |
|
| 1278 | + * |
|
| 1279 | + * @since 1.0.0 |
|
| 1280 | + */ |
|
| 1281 | + public static function render_shortcode() { |
|
| 1282 | + |
|
| 1283 | + check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true ); |
|
| 1284 | + if ( ! current_user_can( 'manage_options' ) ) { |
|
| 1285 | + wp_die(); |
|
| 1286 | + } |
|
| 1287 | + |
|
| 1288 | + // we might need the $post value here so lets set it. |
|
| 1289 | + if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) { |
|
| 1290 | + $post_obj = get_post( absint( $_POST['post_id'] ) ); |
|
| 1291 | + if ( ! empty( $post_obj ) && empty( $post ) ) { |
|
| 1292 | + global $post; |
|
| 1293 | + $post = $post_obj; |
|
| 1294 | + } |
|
| 1295 | + } |
|
| 1296 | + |
|
| 1297 | + if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) { |
|
| 1298 | + $shortcode_name = sanitize_title_with_dashes( $_POST['shortcode'] ); |
|
| 1299 | + $attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array(); |
|
| 1300 | + $attributes = ''; |
|
| 1301 | + if ( ! empty( $attributes_array ) ) { |
|
| 1302 | + foreach ( $attributes_array as $key => $value ) { |
|
| 1303 | + $attributes .= " " . sanitize_title_with_dashes( $key ) . "='" . wp_slash( $value ) . "' "; |
|
| 1304 | + } |
|
| 1305 | + } |
|
| 1306 | + |
|
| 1307 | + $shortcode = "[" . $shortcode_name . " " . $attributes . "]"; |
|
| 1308 | + |
|
| 1309 | + echo do_shortcode( $shortcode ); |
|
| 1310 | + |
|
| 1311 | + } |
|
| 1312 | + wp_die(); |
|
| 1313 | + } |
|
| 1314 | + |
|
| 1315 | + /** |
|
| 1316 | + * Output the shortcode. |
|
| 1317 | + * |
|
| 1318 | + * @param array $args |
|
| 1319 | + * @param string $content |
|
| 1320 | + * |
|
| 1321 | + * @return string |
|
| 1322 | + */ |
|
| 1323 | + public function shortcode_output( $args = array(), $content = '' ) { |
|
| 1324 | + $args = self::argument_values( $args ); |
|
| 1325 | + |
|
| 1326 | + // add extra argument so we know its a output to gutenberg |
|
| 1327 | + //$args |
|
| 1328 | + $args = $this->string_to_bool( $args ); |
|
| 1329 | + |
|
| 1330 | + // if we have a enclosed shortcode we add it to the special `html` argument |
|
| 1331 | + if ( ! empty( $content ) ) { |
|
| 1332 | + $args['html'] = $content; |
|
| 1333 | + } |
|
| 1334 | + |
|
| 1335 | + $class = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : ''; |
|
| 1336 | + |
|
| 1337 | + $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this ); |
|
| 1338 | + $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this ); |
|
| 1339 | + |
|
| 1340 | + $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this ); |
|
| 1341 | + $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this ); //@todo this does not seem right @kiran? |
|
| 1342 | + |
|
| 1343 | + $shortcode_args = array(); |
|
| 1344 | + $output = ''; |
|
| 1345 | + $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false; |
|
| 1346 | + if ( isset( $args['no_wrap'] ) && $args['no_wrap'] ) { |
|
| 1347 | + $no_wrap = true; |
|
| 1348 | + } |
|
| 1349 | + $main_content = $this->output( $args, $shortcode_args, $content ); |
|
| 1350 | + if ( $main_content && ! $no_wrap ) { |
|
| 1351 | + // wrap the shortcode in a div with the same class as the widget |
|
| 1352 | + $output .= '<div class="' . $class . '" ' . $attrs . '>'; |
|
| 1353 | + if ( ! empty( $args['title'] ) ) { |
|
| 1354 | + // if its a shortcode and there is a title try to grab the title wrappers |
|
| 1355 | + $shortcode_args = array( 'before_title' => '', 'after_title' => '' ); |
|
| 1356 | + if ( empty( $instance ) ) { |
|
| 1357 | + global $wp_registered_sidebars; |
|
| 1358 | + if ( ! empty( $wp_registered_sidebars ) ) { |
|
| 1359 | + foreach ( $wp_registered_sidebars as $sidebar ) { |
|
| 1360 | + if ( ! empty( $sidebar['before_title'] ) ) { |
|
| 1361 | + $shortcode_args['before_title'] = $sidebar['before_title']; |
|
| 1362 | + $shortcode_args['after_title'] = $sidebar['after_title']; |
|
| 1363 | + break; |
|
| 1364 | + } |
|
| 1365 | + } |
|
| 1366 | + } |
|
| 1367 | + } |
|
| 1368 | + $output .= $this->output_title( $shortcode_args, $args ); |
|
| 1369 | + } |
|
| 1370 | + $output .= $main_content; |
|
| 1371 | + $output .= '</div>'; |
|
| 1372 | + } elseif ( $main_content && $no_wrap ) { |
|
| 1373 | + $output .= $main_content; |
|
| 1374 | + } |
|
| 1375 | + |
|
| 1376 | + // if preview show a placeholder if empty |
|
| 1377 | + if ( $this->is_preview() && $output == '' ) { |
|
| 1378 | + $output = $this->preview_placeholder_text( "[{" . $this->base_id . "}]" ); |
|
| 1379 | + } |
|
| 1380 | + |
|
| 1381 | + return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this ); |
|
| 1382 | + } |
|
| 1383 | + |
|
| 1384 | + /** |
|
| 1385 | + * Placeholder text to show if output is empty and we are on a preview/builder page. |
|
| 1386 | + * |
|
| 1387 | + * @param string $name |
|
| 1388 | + * |
|
| 1389 | + * @return string |
|
| 1390 | + */ |
|
| 1391 | + public function preview_placeholder_text( $name = '' ) { |
|
| 1392 | + return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf( __( 'Placeholder for: %s' ), $name ) . "</div>"; |
|
| 1393 | + } |
|
| 1394 | + |
|
| 1395 | + /** |
|
| 1396 | + * Sometimes booleans values can be turned to strings, so we fix that. |
|
| 1397 | + * |
|
| 1398 | + * @param $options |
|
| 1399 | + * |
|
| 1400 | + * @return mixed |
|
| 1401 | + */ |
|
| 1402 | + public function string_to_bool( $options ) { |
|
| 1403 | + // convert bool strings to booleans |
|
| 1404 | + foreach ( $options as $key => $val ) { |
|
| 1405 | + if ( $val == 'false' ) { |
|
| 1406 | + $options[ $key ] = false; |
|
| 1407 | + } elseif ( $val == 'true' ) { |
|
| 1408 | + $options[ $key ] = true; |
|
| 1409 | + } |
|
| 1410 | + } |
|
| 1411 | + |
|
| 1412 | + return $options; |
|
| 1413 | + } |
|
| 1414 | + |
|
| 1415 | + /** |
|
| 1416 | + * Get the argument values that are also filterable. |
|
| 1417 | + * |
|
| 1418 | + * @param $instance |
|
| 1419 | + * |
|
| 1420 | + * @since 1.0.12 Don't set checkbox default value if the value is empty. |
|
| 1421 | + * |
|
| 1422 | + * @return array |
|
| 1423 | + */ |
|
| 1424 | + public function argument_values( $instance ) { |
|
| 1425 | + $argument_values = array(); |
|
| 1426 | + |
|
| 1427 | + // set widget instance |
|
| 1428 | + $this->instance = $instance; |
|
| 1429 | + |
|
| 1430 | + if ( empty( $this->arguments ) ) { |
|
| 1431 | + $this->arguments = $this->get_arguments(); |
|
| 1432 | + } |
|
| 1433 | + |
|
| 1434 | + if ( ! empty( $this->arguments ) ) { |
|
| 1435 | + foreach ( $this->arguments as $key => $args ) { |
|
| 1436 | + // set the input name from the key |
|
| 1437 | + $args['name'] = $key; |
|
| 1438 | + // |
|
| 1439 | + $argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : ''; |
|
| 1440 | + if ( $args['type'] == 'checkbox' && $argument_values[ $key ] == '' ) { |
|
| 1441 | + // don't set default for an empty checkbox |
|
| 1442 | + } elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) { |
|
| 1443 | + $argument_values[ $key ] = $args['default']; |
|
| 1444 | + } |
|
| 1445 | + } |
|
| 1446 | + } |
|
| 1447 | + |
|
| 1448 | + return $argument_values; |
|
| 1449 | + } |
|
| 1450 | + |
|
| 1451 | + /** |
|
| 1452 | + * Set arguments in super duper. |
|
| 1453 | + * |
|
| 1454 | + * @since 1.0.0 |
|
| 1455 | + * |
|
| 1456 | + * @return array Set arguments. |
|
| 1457 | + */ |
|
| 1458 | + public function set_arguments() { |
|
| 1459 | + return $this->arguments; |
|
| 1460 | + } |
|
| 1461 | + |
|
| 1462 | + /** |
|
| 1463 | + * Get arguments in super duper. |
|
| 1464 | + * |
|
| 1465 | + * @since 1.0.0 |
|
| 1466 | + * |
|
| 1467 | + * @return array Get arguments. |
|
| 1468 | + */ |
|
| 1469 | + public function get_arguments() { |
|
| 1470 | + if ( empty( $this->arguments ) ) { |
|
| 1471 | + $this->arguments = $this->set_arguments(); |
|
| 1472 | + } |
|
| 1473 | + |
|
| 1474 | + $this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance ); |
|
| 1475 | + $this->arguments = $this->add_name_from_key( $this->arguments, true ); |
|
| 1476 | + |
|
| 1477 | + return $this->arguments; |
|
| 1478 | + } |
|
| 1479 | + |
|
| 1480 | + /** |
|
| 1481 | + * This is the main output class for all 3 items, widget, shortcode and block, it is extended in the calling class. |
|
| 1482 | + * |
|
| 1483 | + * @param array $args |
|
| 1484 | + * @param array $widget_args |
|
| 1485 | + * @param string $content |
|
| 1486 | + */ |
|
| 1487 | + public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 1488 | + |
|
| 1489 | + } |
|
| 1490 | + |
|
| 1491 | + /** |
|
| 1492 | + * Add the dynamic block code inline when the wp-block in enqueued. |
|
| 1493 | + */ |
|
| 1494 | + public function register_block() { |
|
| 1495 | + wp_add_inline_script( 'wp-blocks', $this->block() ); |
|
| 1496 | + if ( class_exists( 'SiteOrigin_Panels' ) ) { |
|
| 1497 | + |
|
| 1498 | + wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() ); |
|
| 1499 | + |
|
| 1500 | + } |
|
| 1501 | + } |
|
| 1502 | + |
|
| 1503 | + /** |
|
| 1504 | + * Check if we need to show advanced options. |
|
| 1505 | + * |
|
| 1506 | + * @return bool |
|
| 1507 | + */ |
|
| 1508 | + public function block_show_advanced() { |
|
| 1509 | + |
|
| 1510 | + $show = false; |
|
| 1511 | + $arguments = $this->arguments; |
|
| 1512 | + |
|
| 1513 | + if ( empty( $arguments ) ) { |
|
| 1514 | + $arguments = $this->get_arguments(); |
|
| 1515 | + } |
|
| 1516 | + |
|
| 1517 | + if ( ! empty( $arguments ) ) { |
|
| 1518 | + foreach ( $arguments as $argument ) { |
|
| 1519 | + if ( isset( $argument['advanced'] ) && $argument['advanced'] ) { |
|
| 1520 | + $show = true; |
|
| 1521 | + break; // no need to continue if we know we have it |
|
| 1522 | + } |
|
| 1523 | + } |
|
| 1524 | + } |
|
| 1525 | + |
|
| 1526 | + return $show; |
|
| 1527 | + } |
|
| 1528 | + |
|
| 1529 | + /** |
|
| 1530 | + * Get the url path to the current folder. |
|
| 1531 | + * |
|
| 1532 | + * @return string |
|
| 1533 | + */ |
|
| 1534 | + public function get_url() { |
|
| 1535 | + |
|
| 1536 | + $url = $this->url; |
|
| 1537 | + |
|
| 1538 | + if ( ! $url ) { |
|
| 1539 | + // check if we are inside a plugin |
|
| 1540 | + $file_dir = str_replace( "/includes", "", dirname( __FILE__ ) ); |
|
| 1541 | + |
|
| 1542 | + $dir_parts = explode( "/wp-content/", $file_dir ); |
|
| 1543 | + $url_parts = explode( "/wp-content/", plugins_url() ); |
|
| 1544 | + |
|
| 1545 | + if ( ! empty( $url_parts[0] ) && ! empty( $dir_parts[1] ) ) { |
|
| 1546 | + $url = trailingslashit( $url_parts[0] . "/wp-content/" . $dir_parts[1] ); |
|
| 1547 | + $this->url = $url; |
|
| 1548 | + } |
|
| 1549 | + } |
|
| 1550 | + |
|
| 1551 | + |
|
| 1552 | + return $url; |
|
| 1553 | + } |
|
| 1554 | + |
|
| 1555 | + /** |
|
| 1556 | + * Generate the block icon. |
|
| 1557 | + * |
|
| 1558 | + * Enables the use of Font Awesome icons. |
|
| 1559 | + * |
|
| 1560 | + * @note xlink:href is actually deprecated but href is not supported by all so we use both. |
|
| 1561 | + * |
|
| 1562 | + * @param $icon |
|
| 1563 | + * |
|
| 1564 | + * @since 1.1.0 |
|
| 1565 | + * @return string |
|
| 1566 | + */ |
|
| 1567 | + public function get_block_icon( $icon ) { |
|
| 1568 | + |
|
| 1569 | + // check if we have a Font Awesome icon |
|
| 1570 | + $fa_type = ''; |
|
| 1571 | + if ( substr( $icon, 0, 7 ) === "fas fa-" ) { |
|
| 1572 | + $fa_type = 'solid'; |
|
| 1573 | + } elseif ( substr( $icon, 0, 7 ) === "far fa-" ) { |
|
| 1574 | + $fa_type = 'regular'; |
|
| 1575 | + } elseif ( substr( $icon, 0, 7 ) === "fab fa-" ) { |
|
| 1576 | + $fa_type = 'brands'; |
|
| 1577 | + } else { |
|
| 1578 | + $icon = "'" . $icon . "'"; |
|
| 1579 | + } |
|
| 1580 | + |
|
| 1581 | + // set the icon if we found one |
|
| 1582 | + if ( $fa_type ) { |
|
| 1583 | + $fa_icon = str_replace( array( "fas fa-", "far fa-", "fab fa-" ), "", $icon ); |
|
| 1584 | + $icon = "el('svg',{width: 20, height: 20, viewBox: '0 0 20 20'},el('use', {'xlink:href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "','href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "'}))"; |
|
| 1585 | + } |
|
| 1586 | + |
|
| 1587 | + return $icon; |
|
| 1588 | + } |
|
| 1589 | + |
|
| 1590 | + public function group_arguments( $arguments ) { |
|
| 1591 | 1591 | // echo '###';print_r($arguments); |
| 1592 | - if ( ! empty( $arguments ) ) { |
|
| 1593 | - $temp_arguments = array(); |
|
| 1594 | - $general = __( "General" ); |
|
| 1595 | - $add_sections = false; |
|
| 1596 | - foreach ( $arguments as $key => $args ) { |
|
| 1597 | - if ( isset( $args['group'] ) ) { |
|
| 1598 | - $temp_arguments[ $args['group'] ][ $key ] = $args; |
|
| 1599 | - $add_sections = true; |
|
| 1600 | - } else { |
|
| 1601 | - $temp_arguments[ $general ][ $key ] = $args; |
|
| 1602 | - } |
|
| 1603 | - } |
|
| 1604 | - |
|
| 1605 | - // only add sections if more than one |
|
| 1606 | - if ( $add_sections ) { |
|
| 1607 | - $arguments = $temp_arguments; |
|
| 1608 | - } |
|
| 1609 | - } |
|
| 1592 | + if ( ! empty( $arguments ) ) { |
|
| 1593 | + $temp_arguments = array(); |
|
| 1594 | + $general = __( "General" ); |
|
| 1595 | + $add_sections = false; |
|
| 1596 | + foreach ( $arguments as $key => $args ) { |
|
| 1597 | + if ( isset( $args['group'] ) ) { |
|
| 1598 | + $temp_arguments[ $args['group'] ][ $key ] = $args; |
|
| 1599 | + $add_sections = true; |
|
| 1600 | + } else { |
|
| 1601 | + $temp_arguments[ $general ][ $key ] = $args; |
|
| 1602 | + } |
|
| 1603 | + } |
|
| 1604 | + |
|
| 1605 | + // only add sections if more than one |
|
| 1606 | + if ( $add_sections ) { |
|
| 1607 | + $arguments = $temp_arguments; |
|
| 1608 | + } |
|
| 1609 | + } |
|
| 1610 | 1610 | |
| 1611 | 1611 | // echo '###';print_r($arguments); |
| 1612 | - return $arguments; |
|
| 1613 | - } |
|
| 1614 | - |
|
| 1615 | - |
|
| 1616 | - /** |
|
| 1617 | - * Output the JS for building the dynamic Guntenberg block. |
|
| 1618 | - * |
|
| 1619 | - * @since 1.0.4 Added block_wrap property which will set the block wrapping output element ie: div, span, p or empty for no wrap. |
|
| 1620 | - * @since 1.0.9 Save numbers as numbers and not strings. |
|
| 1621 | - * @since 1.1.0 Font Awesome classes can be used for icons. |
|
| 1622 | - * @return mixed |
|
| 1623 | - */ |
|
| 1624 | - public function block() { |
|
| 1625 | - ob_start(); |
|
| 1626 | - ?> |
|
| 1612 | + return $arguments; |
|
| 1613 | + } |
|
| 1614 | + |
|
| 1615 | + |
|
| 1616 | + /** |
|
| 1617 | + * Output the JS for building the dynamic Guntenberg block. |
|
| 1618 | + * |
|
| 1619 | + * @since 1.0.4 Added block_wrap property which will set the block wrapping output element ie: div, span, p or empty for no wrap. |
|
| 1620 | + * @since 1.0.9 Save numbers as numbers and not strings. |
|
| 1621 | + * @since 1.1.0 Font Awesome classes can be used for icons. |
|
| 1622 | + * @return mixed |
|
| 1623 | + */ |
|
| 1624 | + public function block() { |
|
| 1625 | + ob_start(); |
|
| 1626 | + ?> |
|
| 1627 | 1627 | <script> |
| 1628 | 1628 | /** |
| 1629 | 1629 | * BLOCK: Basic |
@@ -1662,97 +1662,97 @@ discard block |
||
| 1662 | 1662 | icon: <?php echo $this->get_block_icon( $this->options['block-icon'] );?>,//'<?php echo isset( $this->options['block-icon'] ) ? esc_attr( $this->options['block-icon'] ) : 'shield-alt';?>', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/. |
| 1663 | 1663 | supports: { |
| 1664 | 1664 | <?php |
| 1665 | - if ( isset( $this->options['block-supports'] ) ) { |
|
| 1666 | - echo $this->array_to_attributes( $this->options['block-supports'] ); |
|
| 1667 | - } |
|
| 1668 | - ?> |
|
| 1665 | + if ( isset( $this->options['block-supports'] ) ) { |
|
| 1666 | + echo $this->array_to_attributes( $this->options['block-supports'] ); |
|
| 1667 | + } |
|
| 1668 | + ?> |
|
| 1669 | 1669 | }, |
| 1670 | 1670 | category: '<?php echo isset( $this->options['block-category'] ) ? esc_attr( $this->options['block-category'] ) : 'common';?>', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed. |
| 1671 | 1671 | <?php if ( isset( $this->options['block-keywords'] ) ) { |
| 1672 | - echo "keywords : " . $this->options['block-keywords'] . ","; |
|
| 1673 | - }?> |
|
| 1672 | + echo "keywords : " . $this->options['block-keywords'] . ","; |
|
| 1673 | + }?> |
|
| 1674 | 1674 | |
| 1675 | 1675 | <?php |
| 1676 | 1676 | |
| 1677 | - // maybe set no_wrap |
|
| 1678 | - $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false; |
|
| 1679 | - if ( isset( $this->arguments['no_wrap'] ) && $this->arguments['no_wrap'] ) { |
|
| 1680 | - $no_wrap = true; |
|
| 1681 | - } |
|
| 1682 | - if ( $no_wrap ) { |
|
| 1683 | - $this->options['block-wrap'] = ''; |
|
| 1684 | - } |
|
| 1677 | + // maybe set no_wrap |
|
| 1678 | + $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false; |
|
| 1679 | + if ( isset( $this->arguments['no_wrap'] ) && $this->arguments['no_wrap'] ) { |
|
| 1680 | + $no_wrap = true; |
|
| 1681 | + } |
|
| 1682 | + if ( $no_wrap ) { |
|
| 1683 | + $this->options['block-wrap'] = ''; |
|
| 1684 | + } |
|
| 1685 | 1685 | |
| 1686 | - $show_advanced = $this->block_show_advanced(); |
|
| 1686 | + $show_advanced = $this->block_show_advanced(); |
|
| 1687 | 1687 | |
| 1688 | - $show_alignment = false; |
|
| 1689 | - // align feature |
|
| 1690 | - /*echo "supports: {"; |
|
| 1688 | + $show_alignment = false; |
|
| 1689 | + // align feature |
|
| 1690 | + /*echo "supports: {"; |
|
| 1691 | 1691 | echo " align: true,"; |
| 1692 | 1692 | echo " html: false"; |
| 1693 | 1693 | echo "},";*/ |
| 1694 | 1694 | |
| 1695 | - if ( ! empty( $this->arguments ) ) { |
|
| 1696 | - echo "attributes : {"; |
|
| 1697 | - |
|
| 1698 | - if ( $show_advanced ) { |
|
| 1699 | - echo "show_advanced: {"; |
|
| 1700 | - echo " type: 'boolean',"; |
|
| 1701 | - echo " default: false,"; |
|
| 1702 | - echo "},"; |
|
| 1703 | - } |
|
| 1704 | - |
|
| 1705 | - // block wrap element |
|
| 1706 | - if ( ! empty( $this->options['block-wrap'] ) ) { //@todo we should validate this? |
|
| 1707 | - echo "block_wrap: {"; |
|
| 1708 | - echo " type: 'string',"; |
|
| 1709 | - echo " default: '" . esc_attr( $this->options['block-wrap'] ) . "',"; |
|
| 1710 | - echo "},"; |
|
| 1711 | - } |
|
| 1712 | - |
|
| 1713 | - foreach ( $this->arguments as $key => $args ) { |
|
| 1714 | - |
|
| 1715 | - // set if we should show alignment |
|
| 1716 | - if ( $key == 'alignment' ) { |
|
| 1717 | - $show_alignment = true; |
|
| 1718 | - } |
|
| 1719 | - |
|
| 1720 | - $extra = ''; |
|
| 1721 | - |
|
| 1722 | - if ( $args['type'] == 'checkbox' ) { |
|
| 1723 | - $type = 'boolean'; |
|
| 1724 | - $default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false'; |
|
| 1725 | - } elseif ( $args['type'] == 'number' ) { |
|
| 1726 | - $type = 'number'; |
|
| 1727 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 1728 | - } elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) { |
|
| 1729 | - $type = 'array'; |
|
| 1730 | - if ( is_array( $args['default'] ) ) { |
|
| 1731 | - $default = isset( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]"; |
|
| 1732 | - } else { |
|
| 1733 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 1734 | - } |
|
| 1735 | - } elseif ( $args['type'] == 'multiselect' ) { |
|
| 1736 | - $type = 'array'; |
|
| 1737 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 1738 | - } else { |
|
| 1739 | - $type = 'string'; |
|
| 1740 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 1741 | - } |
|
| 1742 | - echo $key . " : {"; |
|
| 1743 | - echo "type : '$type',"; |
|
| 1744 | - echo "default : $default,"; |
|
| 1745 | - echo "},"; |
|
| 1746 | - } |
|
| 1747 | - |
|
| 1748 | - echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},"; |
|
| 1749 | - echo "className: { type: 'string', default: '' },"; |
|
| 1750 | - |
|
| 1751 | - echo "},"; |
|
| 1752 | - |
|
| 1753 | - } |
|
| 1754 | - |
|
| 1755 | - ?> |
|
| 1695 | + if ( ! empty( $this->arguments ) ) { |
|
| 1696 | + echo "attributes : {"; |
|
| 1697 | + |
|
| 1698 | + if ( $show_advanced ) { |
|
| 1699 | + echo "show_advanced: {"; |
|
| 1700 | + echo " type: 'boolean',"; |
|
| 1701 | + echo " default: false,"; |
|
| 1702 | + echo "},"; |
|
| 1703 | + } |
|
| 1704 | + |
|
| 1705 | + // block wrap element |
|
| 1706 | + if ( ! empty( $this->options['block-wrap'] ) ) { //@todo we should validate this? |
|
| 1707 | + echo "block_wrap: {"; |
|
| 1708 | + echo " type: 'string',"; |
|
| 1709 | + echo " default: '" . esc_attr( $this->options['block-wrap'] ) . "',"; |
|
| 1710 | + echo "},"; |
|
| 1711 | + } |
|
| 1712 | + |
|
| 1713 | + foreach ( $this->arguments as $key => $args ) { |
|
| 1714 | + |
|
| 1715 | + // set if we should show alignment |
|
| 1716 | + if ( $key == 'alignment' ) { |
|
| 1717 | + $show_alignment = true; |
|
| 1718 | + } |
|
| 1719 | + |
|
| 1720 | + $extra = ''; |
|
| 1721 | + |
|
| 1722 | + if ( $args['type'] == 'checkbox' ) { |
|
| 1723 | + $type = 'boolean'; |
|
| 1724 | + $default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false'; |
|
| 1725 | + } elseif ( $args['type'] == 'number' ) { |
|
| 1726 | + $type = 'number'; |
|
| 1727 | + $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 1728 | + } elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) { |
|
| 1729 | + $type = 'array'; |
|
| 1730 | + if ( is_array( $args['default'] ) ) { |
|
| 1731 | + $default = isset( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]"; |
|
| 1732 | + } else { |
|
| 1733 | + $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 1734 | + } |
|
| 1735 | + } elseif ( $args['type'] == 'multiselect' ) { |
|
| 1736 | + $type = 'array'; |
|
| 1737 | + $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 1738 | + } else { |
|
| 1739 | + $type = 'string'; |
|
| 1740 | + $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 1741 | + } |
|
| 1742 | + echo $key . " : {"; |
|
| 1743 | + echo "type : '$type',"; |
|
| 1744 | + echo "default : $default,"; |
|
| 1745 | + echo "},"; |
|
| 1746 | + } |
|
| 1747 | + |
|
| 1748 | + echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},"; |
|
| 1749 | + echo "className: { type: 'string', default: '' },"; |
|
| 1750 | + |
|
| 1751 | + echo "},"; |
|
| 1752 | + |
|
| 1753 | + } |
|
| 1754 | + |
|
| 1755 | + ?> |
|
| 1756 | 1756 | |
| 1757 | 1757 | // The "edit" property must be a valid function. |
| 1758 | 1758 | edit: function (props) { |
@@ -1771,8 +1771,8 @@ discard block |
||
| 1771 | 1771 | 'shortcode': '<?php echo $this->options['base_id'];?>', |
| 1772 | 1772 | 'attributes': props.attributes, |
| 1773 | 1773 | 'post_id': <?php global $post; if ( isset( $post->ID ) ) { |
| 1774 | - echo $post->ID; |
|
| 1775 | - }?>, |
|
| 1774 | + echo $post->ID; |
|
| 1775 | + }?>, |
|
| 1776 | 1776 | '_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>' |
| 1777 | 1777 | }; |
| 1778 | 1778 | |
@@ -1819,10 +1819,10 @@ discard block |
||
| 1819 | 1819 | |
| 1820 | 1820 | <?php |
| 1821 | 1821 | |
| 1822 | - if(! empty( $this->arguments )){ |
|
| 1822 | + if(! empty( $this->arguments )){ |
|
| 1823 | 1823 | |
| 1824 | - if ( $show_advanced ) { |
|
| 1825 | - ?> |
|
| 1824 | + if ( $show_advanced ) { |
|
| 1825 | + ?> |
|
| 1826 | 1826 | el('div', { |
| 1827 | 1827 | style: {'padding-left': '16px','padding-right': '16px'} |
| 1828 | 1828 | }, |
@@ -1840,72 +1840,72 @@ discard block |
||
| 1840 | 1840 | , |
| 1841 | 1841 | <?php |
| 1842 | 1842 | |
| 1843 | - } |
|
| 1843 | + } |
|
| 1844 | 1844 | |
| 1845 | - $arguments = $this->group_arguments( $this->arguments ); |
|
| 1845 | + $arguments = $this->group_arguments( $this->arguments ); |
|
| 1846 | 1846 | |
| 1847 | - // Do we have sections? |
|
| 1848 | - $has_sections = $arguments == $this->arguments ? false : true; |
|
| 1847 | + // Do we have sections? |
|
| 1848 | + $has_sections = $arguments == $this->arguments ? false : true; |
|
| 1849 | 1849 | |
| 1850 | 1850 | |
| 1851 | - if($has_sections){ |
|
| 1852 | - $panel_count = 0; |
|
| 1853 | - foreach($arguments as $key => $args){ |
|
| 1854 | - ?> |
|
| 1851 | + if($has_sections){ |
|
| 1852 | + $panel_count = 0; |
|
| 1853 | + foreach($arguments as $key => $args){ |
|
| 1854 | + ?> |
|
| 1855 | 1855 | el(wp.components.PanelBody, { |
| 1856 | 1856 | title: '<?php esc_attr_e( $key ); ?>', |
| 1857 | 1857 | initialOpen: <?php if ( $panel_count ) { |
| 1858 | - echo "false"; |
|
| 1859 | - } else { |
|
| 1860 | - echo "true"; |
|
| 1861 | - }?> |
|
| 1858 | + echo "false"; |
|
| 1859 | + } else { |
|
| 1860 | + echo "true"; |
|
| 1861 | + }?> |
|
| 1862 | 1862 | }, |
| 1863 | 1863 | <?php |
| 1864 | 1864 | |
| 1865 | - foreach ( $args as $k => $a ) { |
|
| 1866 | - $this->build_block_arguments( $k, $a ); |
|
| 1867 | - } |
|
| 1868 | - ?> |
|
| 1865 | + foreach ( $args as $k => $a ) { |
|
| 1866 | + $this->build_block_arguments( $k, $a ); |
|
| 1867 | + } |
|
| 1868 | + ?> |
|
| 1869 | 1869 | ), |
| 1870 | 1870 | <?php |
| 1871 | - $panel_count ++; |
|
| 1871 | + $panel_count ++; |
|
| 1872 | 1872 | |
| 1873 | - } |
|
| 1874 | - }else { |
|
| 1875 | - ?> |
|
| 1873 | + } |
|
| 1874 | + }else { |
|
| 1875 | + ?> |
|
| 1876 | 1876 | el(wp.components.PanelBody, { |
| 1877 | 1877 | title: '<?php esc_attr_e( "Settings" ); ?>', |
| 1878 | 1878 | initialOpen: true |
| 1879 | 1879 | }, |
| 1880 | 1880 | <?php |
| 1881 | - foreach ( $this->arguments as $key => $args ) { |
|
| 1882 | - $this->build_block_arguments( $key, $args ); |
|
| 1883 | - } |
|
| 1884 | - ?> |
|
| 1881 | + foreach ( $this->arguments as $key => $args ) { |
|
| 1882 | + $this->build_block_arguments( $key, $args ); |
|
| 1883 | + } |
|
| 1884 | + ?> |
|
| 1885 | 1885 | ), |
| 1886 | 1886 | <?php |
| 1887 | - } |
|
| 1887 | + } |
|
| 1888 | 1888 | |
| 1889 | - } |
|
| 1890 | - ?> |
|
| 1889 | + } |
|
| 1890 | + ?> |
|
| 1891 | 1891 | |
| 1892 | 1892 | ), |
| 1893 | 1893 | |
| 1894 | 1894 | <?php |
| 1895 | - // If the user sets block-output array then build it |
|
| 1896 | - if ( ! empty( $this->options['block-output'] ) ) { |
|
| 1897 | - $this->block_element( $this->options['block-output'] ); |
|
| 1898 | - }else{ |
|
| 1899 | - // if no block-output is set then we try and get the shortcode html output via ajax. |
|
| 1900 | - ?> |
|
| 1895 | + // If the user sets block-output array then build it |
|
| 1896 | + if ( ! empty( $this->options['block-output'] ) ) { |
|
| 1897 | + $this->block_element( $this->options['block-output'] ); |
|
| 1898 | + }else{ |
|
| 1899 | + // if no block-output is set then we try and get the shortcode html output via ajax. |
|
| 1900 | + ?> |
|
| 1901 | 1901 | el('div', { |
| 1902 | 1902 | dangerouslySetInnerHTML: {__html: onChangeContent()}, |
| 1903 | 1903 | className: props.className, |
| 1904 | 1904 | style: {'minHeight': '30px'} |
| 1905 | 1905 | }) |
| 1906 | 1906 | <?php |
| 1907 | - } |
|
| 1908 | - ?> |
|
| 1907 | + } |
|
| 1908 | + ?> |
|
| 1909 | 1909 | ]; // end return |
| 1910 | 1910 | }, |
| 1911 | 1911 | |
@@ -1923,10 +1923,10 @@ discard block |
||
| 1923 | 1923 | $html = ''; |
| 1924 | 1924 | <?php |
| 1925 | 1925 | |
| 1926 | - if(! empty( $this->arguments )){ |
|
| 1926 | + if(! empty( $this->arguments )){ |
|
| 1927 | 1927 | |
| 1928 | - foreach($this->arguments as $key => $args){ |
|
| 1929 | - ?> |
|
| 1928 | + foreach($this->arguments as $key => $args){ |
|
| 1929 | + ?> |
|
| 1930 | 1930 | if (attr.hasOwnProperty("<?php echo esc_attr( $key );?>")) { |
| 1931 | 1931 | if ('<?php echo esc_attr( $key );?>' == 'html') { |
| 1932 | 1932 | $html = attr.<?php echo esc_attr( $key );?>; |
@@ -1935,10 +1935,10 @@ discard block |
||
| 1935 | 1935 | } |
| 1936 | 1936 | } |
| 1937 | 1937 | <?php |
| 1938 | - } |
|
| 1939 | - } |
|
| 1938 | + } |
|
| 1939 | + } |
|
| 1940 | 1940 | |
| 1941 | - ?> |
|
| 1941 | + ?> |
|
| 1942 | 1942 | content += "]"; |
| 1943 | 1943 | |
| 1944 | 1944 | // if has html element |
@@ -1961,20 +1961,20 @@ discard block |
||
| 1961 | 1961 | } |
| 1962 | 1962 | |
| 1963 | 1963 | <?php |
| 1964 | - if(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){ |
|
| 1965 | - ?> |
|
| 1964 | + if(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){ |
|
| 1965 | + ?> |
|
| 1966 | 1966 | return content; |
| 1967 | 1967 | <?php |
| 1968 | - }else{ |
|
| 1969 | - ?> |
|
| 1968 | + }else{ |
|
| 1969 | + ?> |
|
| 1970 | 1970 | var block_wrap = 'div'; |
| 1971 | 1971 | if (attr.hasOwnProperty("block_wrap")) { |
| 1972 | 1972 | block_wrap = attr.block_wrap; |
| 1973 | 1973 | } |
| 1974 | 1974 | return el(block_wrap, {dangerouslySetInnerHTML: {__html: content}, className: align}); |
| 1975 | 1975 | <?php |
| 1976 | - } |
|
| 1977 | - ?> |
|
| 1976 | + } |
|
| 1977 | + ?> |
|
| 1978 | 1978 | |
| 1979 | 1979 | |
| 1980 | 1980 | } |
@@ -1982,89 +1982,89 @@ discard block |
||
| 1982 | 1982 | })(); |
| 1983 | 1983 | </script> |
| 1984 | 1984 | <?php |
| 1985 | - $output = ob_get_clean(); |
|
| 1985 | + $output = ob_get_clean(); |
|
| 1986 | 1986 | |
| 1987 | - /* |
|
| 1987 | + /* |
|
| 1988 | 1988 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1989 | 1989 | */ |
| 1990 | 1990 | |
| 1991 | - return str_replace( array( |
|
| 1992 | - '<script>', |
|
| 1993 | - '</script>' |
|
| 1994 | - ), '', $output ); |
|
| 1995 | - } |
|
| 1996 | - |
|
| 1997 | - public function build_block_arguments( $key, $args ) { |
|
| 1998 | - $custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : ''; |
|
| 1999 | - $options = ''; |
|
| 2000 | - $extra = ''; |
|
| 2001 | - $require = ''; |
|
| 2002 | - |
|
| 2003 | - // `content` is a protected and special argument |
|
| 2004 | - if ( $key == 'content' ) { |
|
| 2005 | - return; |
|
| 2006 | - } |
|
| 2007 | - |
|
| 2008 | - $onchange = "props.setAttributes({ $key: $key } )"; |
|
| 2009 | - $value = "props.attributes.$key"; |
|
| 2010 | - $text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'color' ); |
|
| 2011 | - if ( in_array( $args['type'], $text_type ) ) { |
|
| 2012 | - $type = 'TextControl'; |
|
| 2013 | - // Save numbers as numbers and not strings |
|
| 2014 | - if ( $args['type'] == 'number' ) { |
|
| 2015 | - $onchange = "props.setAttributes({ $key: Number($key) } )"; |
|
| 2016 | - } |
|
| 2017 | - } |
|
| 2018 | - // elseif ( $args['type'] == 'color' ) { //@todo ColorPicker labels are not shown yet, we use html5 color input for now https://github.com/WordPress/gutenberg/issues/14378 |
|
| 2019 | - // $type = 'ColorPicker'; |
|
| 2020 | - // } |
|
| 2021 | - elseif ( $args['type'] == 'checkbox' ) { |
|
| 2022 | - $type = 'CheckboxControl'; |
|
| 2023 | - $extra .= "checked: props.attributes.$key,"; |
|
| 2024 | - $onchange = "props.setAttributes({ $key: ! props.attributes.$key } )"; |
|
| 2025 | - } elseif ( $args['type'] == 'textarea' ) { |
|
| 2026 | - $type = 'TextareaControl'; |
|
| 2027 | - } elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) { |
|
| 2028 | - $type = 'SelectControl'; |
|
| 2029 | - if ( ! empty( $args['options'] ) ) { |
|
| 2030 | - $options .= "options: ["; |
|
| 2031 | - foreach ( $args['options'] as $option_val => $option_label ) { |
|
| 2032 | - $options .= "{ value: '" . esc_attr( $option_val ) . "', label: '" . addslashes( $option_label ) . "' },"; |
|
| 2033 | - } |
|
| 2034 | - $options .= "],"; |
|
| 2035 | - } |
|
| 2036 | - if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550 |
|
| 2037 | - $extra .= ' multiple: true, '; |
|
| 2038 | - //$onchange = "props.setAttributes({ $key: ['edit'] } )"; |
|
| 2039 | - //$value = "['edit', 'delete']"; |
|
| 2040 | - } |
|
| 2041 | - } elseif ( $args['type'] == 'alignment' ) { |
|
| 2042 | - $type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example |
|
| 2043 | - } else { |
|
| 2044 | - return;// if we have not implemented the control then don't break the JS. |
|
| 2045 | - } |
|
| 2046 | - |
|
| 2047 | - // add show only if advanced |
|
| 2048 | - if ( ! empty( $args['advanced'] ) ) { |
|
| 2049 | - echo "props.attributes.show_advanced && "; |
|
| 2050 | - } |
|
| 2051 | - // add setting require if defined |
|
| 2052 | - if ( ! empty( $args['element_require'] ) ) { |
|
| 2053 | - echo $this->block_props_replace( $args['element_require'], true ) . " && "; |
|
| 2054 | - } |
|
| 2055 | - ?> |
|
| 1991 | + return str_replace( array( |
|
| 1992 | + '<script>', |
|
| 1993 | + '</script>' |
|
| 1994 | + ), '', $output ); |
|
| 1995 | + } |
|
| 1996 | + |
|
| 1997 | + public function build_block_arguments( $key, $args ) { |
|
| 1998 | + $custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : ''; |
|
| 1999 | + $options = ''; |
|
| 2000 | + $extra = ''; |
|
| 2001 | + $require = ''; |
|
| 2002 | + |
|
| 2003 | + // `content` is a protected and special argument |
|
| 2004 | + if ( $key == 'content' ) { |
|
| 2005 | + return; |
|
| 2006 | + } |
|
| 2007 | + |
|
| 2008 | + $onchange = "props.setAttributes({ $key: $key } )"; |
|
| 2009 | + $value = "props.attributes.$key"; |
|
| 2010 | + $text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'color' ); |
|
| 2011 | + if ( in_array( $args['type'], $text_type ) ) { |
|
| 2012 | + $type = 'TextControl'; |
|
| 2013 | + // Save numbers as numbers and not strings |
|
| 2014 | + if ( $args['type'] == 'number' ) { |
|
| 2015 | + $onchange = "props.setAttributes({ $key: Number($key) } )"; |
|
| 2016 | + } |
|
| 2017 | + } |
|
| 2018 | + // elseif ( $args['type'] == 'color' ) { //@todo ColorPicker labels are not shown yet, we use html5 color input for now https://github.com/WordPress/gutenberg/issues/14378 |
|
| 2019 | + // $type = 'ColorPicker'; |
|
| 2020 | + // } |
|
| 2021 | + elseif ( $args['type'] == 'checkbox' ) { |
|
| 2022 | + $type = 'CheckboxControl'; |
|
| 2023 | + $extra .= "checked: props.attributes.$key,"; |
|
| 2024 | + $onchange = "props.setAttributes({ $key: ! props.attributes.$key } )"; |
|
| 2025 | + } elseif ( $args['type'] == 'textarea' ) { |
|
| 2026 | + $type = 'TextareaControl'; |
|
| 2027 | + } elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) { |
|
| 2028 | + $type = 'SelectControl'; |
|
| 2029 | + if ( ! empty( $args['options'] ) ) { |
|
| 2030 | + $options .= "options: ["; |
|
| 2031 | + foreach ( $args['options'] as $option_val => $option_label ) { |
|
| 2032 | + $options .= "{ value: '" . esc_attr( $option_val ) . "', label: '" . addslashes( $option_label ) . "' },"; |
|
| 2033 | + } |
|
| 2034 | + $options .= "],"; |
|
| 2035 | + } |
|
| 2036 | + if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550 |
|
| 2037 | + $extra .= ' multiple: true, '; |
|
| 2038 | + //$onchange = "props.setAttributes({ $key: ['edit'] } )"; |
|
| 2039 | + //$value = "['edit', 'delete']"; |
|
| 2040 | + } |
|
| 2041 | + } elseif ( $args['type'] == 'alignment' ) { |
|
| 2042 | + $type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example |
|
| 2043 | + } else { |
|
| 2044 | + return;// if we have not implemented the control then don't break the JS. |
|
| 2045 | + } |
|
| 2046 | + |
|
| 2047 | + // add show only if advanced |
|
| 2048 | + if ( ! empty( $args['advanced'] ) ) { |
|
| 2049 | + echo "props.attributes.show_advanced && "; |
|
| 2050 | + } |
|
| 2051 | + // add setting require if defined |
|
| 2052 | + if ( ! empty( $args['element_require'] ) ) { |
|
| 2053 | + echo $this->block_props_replace( $args['element_require'], true ) . " && "; |
|
| 2054 | + } |
|
| 2055 | + ?> |
|
| 2056 | 2056 | el( wp.components.<?php echo $type; ?>, { |
| 2057 | 2057 | label: '<?php echo addslashes( $args['title'] ); ?>', |
| 2058 | 2058 | help: '<?php if ( isset( $args['desc'] ) ) { |
| 2059 | - echo addslashes( $args['desc'] ); |
|
| 2060 | - } ?>', |
|
| 2059 | + echo addslashes( $args['desc'] ); |
|
| 2060 | + } ?>', |
|
| 2061 | 2061 | value: <?php echo $value; ?>, |
| 2062 | 2062 | <?php if ( $type == 'TextControl' && $args['type'] != 'text' ) { |
| 2063 | - echo "type: '" . addslashes( $args['type'] ) . "',"; |
|
| 2064 | - } ?> |
|
| 2063 | + echo "type: '" . addslashes( $args['type'] ) . "',"; |
|
| 2064 | + } ?> |
|
| 2065 | 2065 | <?php if ( ! empty( $args['placeholder'] ) ) { |
| 2066 | - echo "placeholder: '" . addslashes( $args['placeholder'] ) . "',"; |
|
| 2067 | - } ?> |
|
| 2066 | + echo "placeholder: '" . addslashes( $args['placeholder'] ) . "',"; |
|
| 2067 | + } ?> |
|
| 2068 | 2068 | <?php echo $options; ?> |
| 2069 | 2069 | <?php echo $extra; ?> |
| 2070 | 2070 | <?php echo $custom_attributes; ?> |
@@ -2073,527 +2073,527 @@ discard block |
||
| 2073 | 2073 | } |
| 2074 | 2074 | } ), |
| 2075 | 2075 | <?php |
| 2076 | - } |
|
| 2077 | - |
|
| 2078 | - /** |
|
| 2079 | - * Convert an array of attributes to block string. |
|
| 2080 | - * |
|
| 2081 | - * @todo there is prob a faster way to do this, also we could add some validation here. |
|
| 2082 | - * |
|
| 2083 | - * @param $custom_attributes |
|
| 2084 | - * |
|
| 2085 | - * @return string |
|
| 2086 | - */ |
|
| 2087 | - public function array_to_attributes( $custom_attributes, $html = false ) { |
|
| 2088 | - $attributes = ''; |
|
| 2089 | - if ( ! empty( $custom_attributes ) ) { |
|
| 2090 | - |
|
| 2091 | - if ( $html ) { |
|
| 2092 | - foreach ( $custom_attributes as $key => $val ) { |
|
| 2093 | - $attributes .= " $key='$val' "; |
|
| 2094 | - } |
|
| 2095 | - } else { |
|
| 2096 | - foreach ( $custom_attributes as $key => $val ) { |
|
| 2097 | - $attributes .= "'$key': '$val',"; |
|
| 2098 | - } |
|
| 2099 | - } |
|
| 2100 | - } |
|
| 2101 | - |
|
| 2102 | - return $attributes; |
|
| 2103 | - } |
|
| 2104 | - |
|
| 2105 | - /** |
|
| 2106 | - * A self looping function to create the output for JS block elements. |
|
| 2107 | - * |
|
| 2108 | - * This is what is output in the WP Editor visual view. |
|
| 2109 | - * |
|
| 2110 | - * @param $args |
|
| 2111 | - */ |
|
| 2112 | - public function block_element( $args ) { |
|
| 2113 | - |
|
| 2114 | - |
|
| 2115 | - if ( ! empty( $args ) ) { |
|
| 2116 | - foreach ( $args as $element => $new_args ) { |
|
| 2117 | - |
|
| 2118 | - if ( is_array( $new_args ) ) { // its an element |
|
| 2119 | - |
|
| 2120 | - |
|
| 2121 | - if ( isset( $new_args['element'] ) ) { |
|
| 2122 | - |
|
| 2123 | - if ( isset( $new_args['element_require'] ) ) { |
|
| 2124 | - echo str_replace( array( |
|
| 2125 | - "'+", |
|
| 2126 | - "+'" |
|
| 2127 | - ), '', $this->block_props_replace( $new_args['element_require'] ) ) . " && "; |
|
| 2128 | - unset( $new_args['element_require'] ); |
|
| 2129 | - } |
|
| 2130 | - |
|
| 2131 | - echo "\n el( '" . $new_args['element'] . "', {"; |
|
| 2132 | - |
|
| 2133 | - // get the attributes |
|
| 2134 | - foreach ( $new_args as $new_key => $new_value ) { |
|
| 2135 | - |
|
| 2136 | - |
|
| 2137 | - if ( $new_key == 'element' || $new_key == 'content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) { |
|
| 2138 | - // do nothing |
|
| 2139 | - } else { |
|
| 2140 | - echo $this->block_element( array( $new_key => $new_value ) ); |
|
| 2141 | - } |
|
| 2142 | - } |
|
| 2143 | - |
|
| 2144 | - echo "},";// end attributes |
|
| 2145 | - |
|
| 2146 | - // get the content |
|
| 2147 | - $first_item = 0; |
|
| 2148 | - foreach ( $new_args as $new_key => $new_value ) { |
|
| 2149 | - if ( $new_key === 'content' || is_array( $new_value ) ) { |
|
| 2150 | - |
|
| 2151 | - if ( $new_key === 'content' ) { |
|
| 2152 | - echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'"; |
|
| 2153 | - } |
|
| 2154 | - |
|
| 2155 | - if ( is_array( $new_value ) ) { |
|
| 2156 | - |
|
| 2157 | - if ( isset( $new_value['element_require'] ) ) { |
|
| 2158 | - echo str_replace( array( |
|
| 2159 | - "'+", |
|
| 2160 | - "+'" |
|
| 2161 | - ), '', $this->block_props_replace( $new_value['element_require'] ) ) . " && "; |
|
| 2162 | - unset( $new_value['element_require'] ); |
|
| 2163 | - } |
|
| 2164 | - |
|
| 2165 | - if ( isset( $new_value['element_repeat'] ) ) { |
|
| 2166 | - $x = 1; |
|
| 2167 | - while ( $x <= absint( $new_value['element_repeat'] ) ) { |
|
| 2168 | - $this->block_element( array( '' => $new_value ) ); |
|
| 2169 | - $x ++; |
|
| 2170 | - } |
|
| 2171 | - } else { |
|
| 2172 | - $this->block_element( array( '' => $new_value ) ); |
|
| 2173 | - } |
|
| 2174 | - } |
|
| 2175 | - $first_item ++; |
|
| 2176 | - } |
|
| 2177 | - } |
|
| 2178 | - |
|
| 2179 | - echo ")";// end content |
|
| 2180 | - |
|
| 2181 | - echo ", \n"; |
|
| 2182 | - |
|
| 2183 | - } |
|
| 2184 | - } else { |
|
| 2185 | - |
|
| 2186 | - if ( substr( $element, 0, 3 ) === "if_" ) { |
|
| 2187 | - echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ","; |
|
| 2188 | - } elseif ( $element == 'style' ) { |
|
| 2189 | - echo $element . ": " . $this->block_props_replace( $new_args ) . ","; |
|
| 2190 | - } else { |
|
| 2191 | - echo $element . ": '" . $this->block_props_replace( $new_args ) . "',"; |
|
| 2192 | - } |
|
| 2193 | - |
|
| 2194 | - } |
|
| 2195 | - } |
|
| 2196 | - } |
|
| 2197 | - } |
|
| 2198 | - |
|
| 2199 | - /** |
|
| 2200 | - * Replace block attributes placeholders with the proper naming. |
|
| 2201 | - * |
|
| 2202 | - * @param $string |
|
| 2203 | - * |
|
| 2204 | - * @return mixed |
|
| 2205 | - */ |
|
| 2206 | - public function block_props_replace( $string, $no_wrap = false ) { |
|
| 2207 | - |
|
| 2208 | - if ( $no_wrap ) { |
|
| 2209 | - $string = str_replace( array( "[%", "%]" ), array( "props.attributes.", "" ), $string ); |
|
| 2210 | - } else { |
|
| 2211 | - $string = str_replace( array( "[%", "%]" ), array( "'+props.attributes.", "+'" ), $string ); |
|
| 2212 | - } |
|
| 2213 | - |
|
| 2214 | - return $string; |
|
| 2215 | - } |
|
| 2216 | - |
|
| 2217 | - /** |
|
| 2218 | - * Outputs the content of the widget |
|
| 2219 | - * |
|
| 2220 | - * @param array $args |
|
| 2221 | - * @param array $instance |
|
| 2222 | - */ |
|
| 2223 | - public function widget( $args, $instance ) { |
|
| 2224 | - |
|
| 2225 | - // get the filtered values |
|
| 2226 | - $argument_values = $this->argument_values( $instance ); |
|
| 2227 | - $argument_values = $this->string_to_bool( $argument_values ); |
|
| 2228 | - $output = $this->output( $argument_values, $args ); |
|
| 2229 | - |
|
| 2230 | - $no_wrap = false; |
|
| 2231 | - if ( isset( $argument_values['no_wrap'] ) && $argument_values['no_wrap'] ) { |
|
| 2232 | - $no_wrap = true; |
|
| 2233 | - } |
|
| 2234 | - |
|
| 2235 | - ob_start(); |
|
| 2236 | - if ( $output && ! $no_wrap ) { |
|
| 2237 | - // Before widget |
|
| 2238 | - $before_widget = $args['before_widget']; |
|
| 2239 | - $before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this ); |
|
| 2240 | - $before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this ); |
|
| 2241 | - |
|
| 2242 | - // After widget |
|
| 2243 | - $after_widget = $args['after_widget']; |
|
| 2244 | - $after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this ); |
|
| 2245 | - $after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this ); |
|
| 2246 | - |
|
| 2247 | - echo $before_widget; |
|
| 2248 | - // elementor strips the widget wrapping div so we check for and add it back if needed |
|
| 2249 | - if ( $this->is_elementor_widget_output() ) { |
|
| 2250 | - echo ! empty( $this->options['widget_ops']['classname'] ) ? "<span class='" . esc_attr( $this->options['widget_ops']['classname'] ) . "'>" : ''; |
|
| 2251 | - } |
|
| 2252 | - echo $this->output_title( $args, $instance ); |
|
| 2253 | - echo $output; |
|
| 2254 | - if ( $this->is_elementor_widget_output() ) { |
|
| 2255 | - echo ! empty( $this->options['widget_ops']['classname'] ) ? "</span>" : ''; |
|
| 2256 | - } |
|
| 2257 | - echo $after_widget; |
|
| 2258 | - } elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty |
|
| 2259 | - $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" ); |
|
| 2260 | - echo $output; |
|
| 2261 | - } elseif ( $output && $no_wrap ) { |
|
| 2262 | - echo $output; |
|
| 2263 | - } |
|
| 2264 | - $output = ob_get_clean(); |
|
| 2265 | - |
|
| 2266 | - $output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this ); |
|
| 2267 | - |
|
| 2268 | - echo $output; |
|
| 2269 | - } |
|
| 2270 | - |
|
| 2271 | - /** |
|
| 2272 | - * Tests if the current output is inside a elementor container. |
|
| 2273 | - * |
|
| 2274 | - * @since 1.0.4 |
|
| 2275 | - * @return bool |
|
| 2276 | - */ |
|
| 2277 | - public function is_elementor_widget_output() { |
|
| 2278 | - $result = false; |
|
| 2279 | - if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) { |
|
| 2280 | - $result = true; |
|
| 2281 | - } |
|
| 2282 | - |
|
| 2283 | - return $result; |
|
| 2284 | - } |
|
| 2285 | - |
|
| 2286 | - /** |
|
| 2287 | - * Tests if the current output is inside a elementor preview. |
|
| 2288 | - * |
|
| 2289 | - * @since 1.0.4 |
|
| 2290 | - * @return bool |
|
| 2291 | - */ |
|
| 2292 | - public function is_elementor_preview() { |
|
| 2293 | - $result = false; |
|
| 2294 | - if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) { |
|
| 2295 | - $result = true; |
|
| 2296 | - } |
|
| 2297 | - |
|
| 2298 | - return $result; |
|
| 2299 | - } |
|
| 2300 | - |
|
| 2301 | - /** |
|
| 2302 | - * Tests if the current output is inside a Divi preview. |
|
| 2303 | - * |
|
| 2304 | - * @since 1.0.6 |
|
| 2305 | - * @return bool |
|
| 2306 | - */ |
|
| 2307 | - public function is_divi_preview() { |
|
| 2308 | - $result = false; |
|
| 2309 | - if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) { |
|
| 2310 | - $result = true; |
|
| 2311 | - } |
|
| 2312 | - |
|
| 2313 | - return $result; |
|
| 2314 | - } |
|
| 2315 | - |
|
| 2316 | - /** |
|
| 2317 | - * Tests if the current output is inside a Beaver builder preview. |
|
| 2318 | - * |
|
| 2319 | - * @since 1.0.6 |
|
| 2320 | - * @return bool |
|
| 2321 | - */ |
|
| 2322 | - public function is_beaver_preview() { |
|
| 2323 | - $result = false; |
|
| 2324 | - if ( isset( $_REQUEST['fl_builder'] ) ) { |
|
| 2325 | - $result = true; |
|
| 2326 | - } |
|
| 2327 | - |
|
| 2328 | - return $result; |
|
| 2329 | - } |
|
| 2330 | - |
|
| 2331 | - /** |
|
| 2332 | - * Tests if the current output is inside a siteorigin builder preview. |
|
| 2333 | - * |
|
| 2334 | - * @since 1.0.6 |
|
| 2335 | - * @return bool |
|
| 2336 | - */ |
|
| 2337 | - public function is_siteorigin_preview() { |
|
| 2338 | - $result = false; |
|
| 2339 | - if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) { |
|
| 2340 | - $result = true; |
|
| 2341 | - } |
|
| 2342 | - |
|
| 2343 | - return $result; |
|
| 2344 | - } |
|
| 2345 | - |
|
| 2346 | - /** |
|
| 2347 | - * Tests if the current output is inside a cornerstone builder preview. |
|
| 2348 | - * |
|
| 2349 | - * @since 1.0.8 |
|
| 2350 | - * @return bool |
|
| 2351 | - */ |
|
| 2352 | - public function is_cornerstone_preview() { |
|
| 2353 | - $result = false; |
|
| 2354 | - if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) { |
|
| 2355 | - $result = true; |
|
| 2356 | - } |
|
| 2357 | - |
|
| 2358 | - return $result; |
|
| 2359 | - } |
|
| 2360 | - |
|
| 2361 | - /** |
|
| 2362 | - * Tests if the current output is inside a fusion builder preview. |
|
| 2363 | - * |
|
| 2364 | - * @since 1.1.0 |
|
| 2365 | - * @return bool |
|
| 2366 | - */ |
|
| 2367 | - public function is_fusion_preview() { |
|
| 2368 | - $result = false; |
|
| 2369 | - if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) { |
|
| 2370 | - $result = true; |
|
| 2371 | - } |
|
| 2372 | - |
|
| 2373 | - return $result; |
|
| 2374 | - } |
|
| 2375 | - |
|
| 2376 | - /** |
|
| 2377 | - * Tests if the current output is inside a Oxygen builder preview. |
|
| 2378 | - * |
|
| 2379 | - * @since 1.0.18 |
|
| 2380 | - * @return bool |
|
| 2381 | - */ |
|
| 2382 | - public function is_oxygen_preview() { |
|
| 2383 | - $result = false; |
|
| 2384 | - if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) { |
|
| 2385 | - $result = true; |
|
| 2386 | - } |
|
| 2387 | - |
|
| 2388 | - return $result; |
|
| 2389 | - } |
|
| 2390 | - |
|
| 2391 | - /** |
|
| 2392 | - * General function to check if we are in a preview situation. |
|
| 2393 | - * |
|
| 2394 | - * @since 1.0.6 |
|
| 2395 | - * @return bool |
|
| 2396 | - */ |
|
| 2397 | - public function is_preview() { |
|
| 2398 | - $preview = false; |
|
| 2399 | - if ( $this->is_divi_preview() ) { |
|
| 2400 | - $preview = true; |
|
| 2401 | - } elseif ( $this->is_elementor_preview() ) { |
|
| 2402 | - $preview = true; |
|
| 2403 | - } elseif ( $this->is_beaver_preview() ) { |
|
| 2404 | - $preview = true; |
|
| 2405 | - } elseif ( $this->is_siteorigin_preview() ) { |
|
| 2406 | - $preview = true; |
|
| 2407 | - } elseif ( $this->is_cornerstone_preview() ) { |
|
| 2408 | - $preview = true; |
|
| 2409 | - } elseif ( $this->is_fusion_preview() ) { |
|
| 2410 | - $preview = true; |
|
| 2411 | - } elseif ( $this->is_oxygen_preview() ) { |
|
| 2412 | - $preview = true; |
|
| 2413 | - } |
|
| 2414 | - |
|
| 2415 | - return $preview; |
|
| 2416 | - } |
|
| 2417 | - |
|
| 2418 | - /** |
|
| 2419 | - * Output the super title. |
|
| 2420 | - * |
|
| 2421 | - * @param $args |
|
| 2422 | - * @param array $instance |
|
| 2423 | - * |
|
| 2424 | - * @return string |
|
| 2425 | - */ |
|
| 2426 | - public function output_title( $args, $instance = array() ) { |
|
| 2427 | - $output = ''; |
|
| 2428 | - if ( ! empty( $instance['title'] ) ) { |
|
| 2429 | - /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ |
|
| 2430 | - $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); |
|
| 2431 | - $output = $args['before_title'] . $title . $args['after_title']; |
|
| 2432 | - } |
|
| 2433 | - |
|
| 2434 | - return $output; |
|
| 2435 | - } |
|
| 2436 | - |
|
| 2437 | - /** |
|
| 2438 | - * Outputs the options form inputs for the widget. |
|
| 2439 | - * |
|
| 2440 | - * @param array $instance The widget options. |
|
| 2441 | - */ |
|
| 2442 | - public function form( $instance ) { |
|
| 2443 | - |
|
| 2444 | - // set widget instance |
|
| 2445 | - $this->instance = $instance; |
|
| 2446 | - |
|
| 2447 | - // set it as a SD widget |
|
| 2448 | - echo $this->widget_advanced_toggle(); |
|
| 2449 | - |
|
| 2450 | - echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>"; |
|
| 2451 | - $arguments_raw = $this->get_arguments(); |
|
| 2452 | - |
|
| 2453 | - if ( is_array( $arguments_raw ) ) { |
|
| 2454 | - |
|
| 2455 | - $arguments = $this->group_arguments( $arguments_raw ); |
|
| 2456 | - |
|
| 2457 | - // Do we have sections? |
|
| 2458 | - $has_sections = $arguments == $arguments_raw ? false : true; |
|
| 2459 | - |
|
| 2460 | - |
|
| 2461 | - if ( $has_sections ) { |
|
| 2462 | - $panel_count = 0; |
|
| 2463 | - foreach ( $arguments as $key => $args ) { |
|
| 2464 | - |
|
| 2465 | - ?> |
|
| 2076 | + } |
|
| 2077 | + |
|
| 2078 | + /** |
|
| 2079 | + * Convert an array of attributes to block string. |
|
| 2080 | + * |
|
| 2081 | + * @todo there is prob a faster way to do this, also we could add some validation here. |
|
| 2082 | + * |
|
| 2083 | + * @param $custom_attributes |
|
| 2084 | + * |
|
| 2085 | + * @return string |
|
| 2086 | + */ |
|
| 2087 | + public function array_to_attributes( $custom_attributes, $html = false ) { |
|
| 2088 | + $attributes = ''; |
|
| 2089 | + if ( ! empty( $custom_attributes ) ) { |
|
| 2090 | + |
|
| 2091 | + if ( $html ) { |
|
| 2092 | + foreach ( $custom_attributes as $key => $val ) { |
|
| 2093 | + $attributes .= " $key='$val' "; |
|
| 2094 | + } |
|
| 2095 | + } else { |
|
| 2096 | + foreach ( $custom_attributes as $key => $val ) { |
|
| 2097 | + $attributes .= "'$key': '$val',"; |
|
| 2098 | + } |
|
| 2099 | + } |
|
| 2100 | + } |
|
| 2101 | + |
|
| 2102 | + return $attributes; |
|
| 2103 | + } |
|
| 2104 | + |
|
| 2105 | + /** |
|
| 2106 | + * A self looping function to create the output for JS block elements. |
|
| 2107 | + * |
|
| 2108 | + * This is what is output in the WP Editor visual view. |
|
| 2109 | + * |
|
| 2110 | + * @param $args |
|
| 2111 | + */ |
|
| 2112 | + public function block_element( $args ) { |
|
| 2113 | + |
|
| 2114 | + |
|
| 2115 | + if ( ! empty( $args ) ) { |
|
| 2116 | + foreach ( $args as $element => $new_args ) { |
|
| 2117 | + |
|
| 2118 | + if ( is_array( $new_args ) ) { // its an element |
|
| 2119 | + |
|
| 2120 | + |
|
| 2121 | + if ( isset( $new_args['element'] ) ) { |
|
| 2122 | + |
|
| 2123 | + if ( isset( $new_args['element_require'] ) ) { |
|
| 2124 | + echo str_replace( array( |
|
| 2125 | + "'+", |
|
| 2126 | + "+'" |
|
| 2127 | + ), '', $this->block_props_replace( $new_args['element_require'] ) ) . " && "; |
|
| 2128 | + unset( $new_args['element_require'] ); |
|
| 2129 | + } |
|
| 2130 | + |
|
| 2131 | + echo "\n el( '" . $new_args['element'] . "', {"; |
|
| 2132 | + |
|
| 2133 | + // get the attributes |
|
| 2134 | + foreach ( $new_args as $new_key => $new_value ) { |
|
| 2135 | + |
|
| 2136 | + |
|
| 2137 | + if ( $new_key == 'element' || $new_key == 'content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) { |
|
| 2138 | + // do nothing |
|
| 2139 | + } else { |
|
| 2140 | + echo $this->block_element( array( $new_key => $new_value ) ); |
|
| 2141 | + } |
|
| 2142 | + } |
|
| 2143 | + |
|
| 2144 | + echo "},";// end attributes |
|
| 2145 | + |
|
| 2146 | + // get the content |
|
| 2147 | + $first_item = 0; |
|
| 2148 | + foreach ( $new_args as $new_key => $new_value ) { |
|
| 2149 | + if ( $new_key === 'content' || is_array( $new_value ) ) { |
|
| 2150 | + |
|
| 2151 | + if ( $new_key === 'content' ) { |
|
| 2152 | + echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'"; |
|
| 2153 | + } |
|
| 2154 | + |
|
| 2155 | + if ( is_array( $new_value ) ) { |
|
| 2156 | + |
|
| 2157 | + if ( isset( $new_value['element_require'] ) ) { |
|
| 2158 | + echo str_replace( array( |
|
| 2159 | + "'+", |
|
| 2160 | + "+'" |
|
| 2161 | + ), '', $this->block_props_replace( $new_value['element_require'] ) ) . " && "; |
|
| 2162 | + unset( $new_value['element_require'] ); |
|
| 2163 | + } |
|
| 2164 | + |
|
| 2165 | + if ( isset( $new_value['element_repeat'] ) ) { |
|
| 2166 | + $x = 1; |
|
| 2167 | + while ( $x <= absint( $new_value['element_repeat'] ) ) { |
|
| 2168 | + $this->block_element( array( '' => $new_value ) ); |
|
| 2169 | + $x ++; |
|
| 2170 | + } |
|
| 2171 | + } else { |
|
| 2172 | + $this->block_element( array( '' => $new_value ) ); |
|
| 2173 | + } |
|
| 2174 | + } |
|
| 2175 | + $first_item ++; |
|
| 2176 | + } |
|
| 2177 | + } |
|
| 2178 | + |
|
| 2179 | + echo ")";// end content |
|
| 2180 | + |
|
| 2181 | + echo ", \n"; |
|
| 2182 | + |
|
| 2183 | + } |
|
| 2184 | + } else { |
|
| 2185 | + |
|
| 2186 | + if ( substr( $element, 0, 3 ) === "if_" ) { |
|
| 2187 | + echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ","; |
|
| 2188 | + } elseif ( $element == 'style' ) { |
|
| 2189 | + echo $element . ": " . $this->block_props_replace( $new_args ) . ","; |
|
| 2190 | + } else { |
|
| 2191 | + echo $element . ": '" . $this->block_props_replace( $new_args ) . "',"; |
|
| 2192 | + } |
|
| 2193 | + |
|
| 2194 | + } |
|
| 2195 | + } |
|
| 2196 | + } |
|
| 2197 | + } |
|
| 2198 | + |
|
| 2199 | + /** |
|
| 2200 | + * Replace block attributes placeholders with the proper naming. |
|
| 2201 | + * |
|
| 2202 | + * @param $string |
|
| 2203 | + * |
|
| 2204 | + * @return mixed |
|
| 2205 | + */ |
|
| 2206 | + public function block_props_replace( $string, $no_wrap = false ) { |
|
| 2207 | + |
|
| 2208 | + if ( $no_wrap ) { |
|
| 2209 | + $string = str_replace( array( "[%", "%]" ), array( "props.attributes.", "" ), $string ); |
|
| 2210 | + } else { |
|
| 2211 | + $string = str_replace( array( "[%", "%]" ), array( "'+props.attributes.", "+'" ), $string ); |
|
| 2212 | + } |
|
| 2213 | + |
|
| 2214 | + return $string; |
|
| 2215 | + } |
|
| 2216 | + |
|
| 2217 | + /** |
|
| 2218 | + * Outputs the content of the widget |
|
| 2219 | + * |
|
| 2220 | + * @param array $args |
|
| 2221 | + * @param array $instance |
|
| 2222 | + */ |
|
| 2223 | + public function widget( $args, $instance ) { |
|
| 2224 | + |
|
| 2225 | + // get the filtered values |
|
| 2226 | + $argument_values = $this->argument_values( $instance ); |
|
| 2227 | + $argument_values = $this->string_to_bool( $argument_values ); |
|
| 2228 | + $output = $this->output( $argument_values, $args ); |
|
| 2229 | + |
|
| 2230 | + $no_wrap = false; |
|
| 2231 | + if ( isset( $argument_values['no_wrap'] ) && $argument_values['no_wrap'] ) { |
|
| 2232 | + $no_wrap = true; |
|
| 2233 | + } |
|
| 2234 | + |
|
| 2235 | + ob_start(); |
|
| 2236 | + if ( $output && ! $no_wrap ) { |
|
| 2237 | + // Before widget |
|
| 2238 | + $before_widget = $args['before_widget']; |
|
| 2239 | + $before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this ); |
|
| 2240 | + $before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this ); |
|
| 2241 | + |
|
| 2242 | + // After widget |
|
| 2243 | + $after_widget = $args['after_widget']; |
|
| 2244 | + $after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this ); |
|
| 2245 | + $after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this ); |
|
| 2246 | + |
|
| 2247 | + echo $before_widget; |
|
| 2248 | + // elementor strips the widget wrapping div so we check for and add it back if needed |
|
| 2249 | + if ( $this->is_elementor_widget_output() ) { |
|
| 2250 | + echo ! empty( $this->options['widget_ops']['classname'] ) ? "<span class='" . esc_attr( $this->options['widget_ops']['classname'] ) . "'>" : ''; |
|
| 2251 | + } |
|
| 2252 | + echo $this->output_title( $args, $instance ); |
|
| 2253 | + echo $output; |
|
| 2254 | + if ( $this->is_elementor_widget_output() ) { |
|
| 2255 | + echo ! empty( $this->options['widget_ops']['classname'] ) ? "</span>" : ''; |
|
| 2256 | + } |
|
| 2257 | + echo $after_widget; |
|
| 2258 | + } elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty |
|
| 2259 | + $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" ); |
|
| 2260 | + echo $output; |
|
| 2261 | + } elseif ( $output && $no_wrap ) { |
|
| 2262 | + echo $output; |
|
| 2263 | + } |
|
| 2264 | + $output = ob_get_clean(); |
|
| 2265 | + |
|
| 2266 | + $output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this ); |
|
| 2267 | + |
|
| 2268 | + echo $output; |
|
| 2269 | + } |
|
| 2270 | + |
|
| 2271 | + /** |
|
| 2272 | + * Tests if the current output is inside a elementor container. |
|
| 2273 | + * |
|
| 2274 | + * @since 1.0.4 |
|
| 2275 | + * @return bool |
|
| 2276 | + */ |
|
| 2277 | + public function is_elementor_widget_output() { |
|
| 2278 | + $result = false; |
|
| 2279 | + if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) { |
|
| 2280 | + $result = true; |
|
| 2281 | + } |
|
| 2282 | + |
|
| 2283 | + return $result; |
|
| 2284 | + } |
|
| 2285 | + |
|
| 2286 | + /** |
|
| 2287 | + * Tests if the current output is inside a elementor preview. |
|
| 2288 | + * |
|
| 2289 | + * @since 1.0.4 |
|
| 2290 | + * @return bool |
|
| 2291 | + */ |
|
| 2292 | + public function is_elementor_preview() { |
|
| 2293 | + $result = false; |
|
| 2294 | + if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) { |
|
| 2295 | + $result = true; |
|
| 2296 | + } |
|
| 2297 | + |
|
| 2298 | + return $result; |
|
| 2299 | + } |
|
| 2300 | + |
|
| 2301 | + /** |
|
| 2302 | + * Tests if the current output is inside a Divi preview. |
|
| 2303 | + * |
|
| 2304 | + * @since 1.0.6 |
|
| 2305 | + * @return bool |
|
| 2306 | + */ |
|
| 2307 | + public function is_divi_preview() { |
|
| 2308 | + $result = false; |
|
| 2309 | + if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) { |
|
| 2310 | + $result = true; |
|
| 2311 | + } |
|
| 2312 | + |
|
| 2313 | + return $result; |
|
| 2314 | + } |
|
| 2315 | + |
|
| 2316 | + /** |
|
| 2317 | + * Tests if the current output is inside a Beaver builder preview. |
|
| 2318 | + * |
|
| 2319 | + * @since 1.0.6 |
|
| 2320 | + * @return bool |
|
| 2321 | + */ |
|
| 2322 | + public function is_beaver_preview() { |
|
| 2323 | + $result = false; |
|
| 2324 | + if ( isset( $_REQUEST['fl_builder'] ) ) { |
|
| 2325 | + $result = true; |
|
| 2326 | + } |
|
| 2327 | + |
|
| 2328 | + return $result; |
|
| 2329 | + } |
|
| 2330 | + |
|
| 2331 | + /** |
|
| 2332 | + * Tests if the current output is inside a siteorigin builder preview. |
|
| 2333 | + * |
|
| 2334 | + * @since 1.0.6 |
|
| 2335 | + * @return bool |
|
| 2336 | + */ |
|
| 2337 | + public function is_siteorigin_preview() { |
|
| 2338 | + $result = false; |
|
| 2339 | + if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) { |
|
| 2340 | + $result = true; |
|
| 2341 | + } |
|
| 2342 | + |
|
| 2343 | + return $result; |
|
| 2344 | + } |
|
| 2345 | + |
|
| 2346 | + /** |
|
| 2347 | + * Tests if the current output is inside a cornerstone builder preview. |
|
| 2348 | + * |
|
| 2349 | + * @since 1.0.8 |
|
| 2350 | + * @return bool |
|
| 2351 | + */ |
|
| 2352 | + public function is_cornerstone_preview() { |
|
| 2353 | + $result = false; |
|
| 2354 | + if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) { |
|
| 2355 | + $result = true; |
|
| 2356 | + } |
|
| 2357 | + |
|
| 2358 | + return $result; |
|
| 2359 | + } |
|
| 2360 | + |
|
| 2361 | + /** |
|
| 2362 | + * Tests if the current output is inside a fusion builder preview. |
|
| 2363 | + * |
|
| 2364 | + * @since 1.1.0 |
|
| 2365 | + * @return bool |
|
| 2366 | + */ |
|
| 2367 | + public function is_fusion_preview() { |
|
| 2368 | + $result = false; |
|
| 2369 | + if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) { |
|
| 2370 | + $result = true; |
|
| 2371 | + } |
|
| 2372 | + |
|
| 2373 | + return $result; |
|
| 2374 | + } |
|
| 2375 | + |
|
| 2376 | + /** |
|
| 2377 | + * Tests if the current output is inside a Oxygen builder preview. |
|
| 2378 | + * |
|
| 2379 | + * @since 1.0.18 |
|
| 2380 | + * @return bool |
|
| 2381 | + */ |
|
| 2382 | + public function is_oxygen_preview() { |
|
| 2383 | + $result = false; |
|
| 2384 | + if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) { |
|
| 2385 | + $result = true; |
|
| 2386 | + } |
|
| 2387 | + |
|
| 2388 | + return $result; |
|
| 2389 | + } |
|
| 2390 | + |
|
| 2391 | + /** |
|
| 2392 | + * General function to check if we are in a preview situation. |
|
| 2393 | + * |
|
| 2394 | + * @since 1.0.6 |
|
| 2395 | + * @return bool |
|
| 2396 | + */ |
|
| 2397 | + public function is_preview() { |
|
| 2398 | + $preview = false; |
|
| 2399 | + if ( $this->is_divi_preview() ) { |
|
| 2400 | + $preview = true; |
|
| 2401 | + } elseif ( $this->is_elementor_preview() ) { |
|
| 2402 | + $preview = true; |
|
| 2403 | + } elseif ( $this->is_beaver_preview() ) { |
|
| 2404 | + $preview = true; |
|
| 2405 | + } elseif ( $this->is_siteorigin_preview() ) { |
|
| 2406 | + $preview = true; |
|
| 2407 | + } elseif ( $this->is_cornerstone_preview() ) { |
|
| 2408 | + $preview = true; |
|
| 2409 | + } elseif ( $this->is_fusion_preview() ) { |
|
| 2410 | + $preview = true; |
|
| 2411 | + } elseif ( $this->is_oxygen_preview() ) { |
|
| 2412 | + $preview = true; |
|
| 2413 | + } |
|
| 2414 | + |
|
| 2415 | + return $preview; |
|
| 2416 | + } |
|
| 2417 | + |
|
| 2418 | + /** |
|
| 2419 | + * Output the super title. |
|
| 2420 | + * |
|
| 2421 | + * @param $args |
|
| 2422 | + * @param array $instance |
|
| 2423 | + * |
|
| 2424 | + * @return string |
|
| 2425 | + */ |
|
| 2426 | + public function output_title( $args, $instance = array() ) { |
|
| 2427 | + $output = ''; |
|
| 2428 | + if ( ! empty( $instance['title'] ) ) { |
|
| 2429 | + /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ |
|
| 2430 | + $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); |
|
| 2431 | + $output = $args['before_title'] . $title . $args['after_title']; |
|
| 2432 | + } |
|
| 2433 | + |
|
| 2434 | + return $output; |
|
| 2435 | + } |
|
| 2436 | + |
|
| 2437 | + /** |
|
| 2438 | + * Outputs the options form inputs for the widget. |
|
| 2439 | + * |
|
| 2440 | + * @param array $instance The widget options. |
|
| 2441 | + */ |
|
| 2442 | + public function form( $instance ) { |
|
| 2443 | + |
|
| 2444 | + // set widget instance |
|
| 2445 | + $this->instance = $instance; |
|
| 2446 | + |
|
| 2447 | + // set it as a SD widget |
|
| 2448 | + echo $this->widget_advanced_toggle(); |
|
| 2449 | + |
|
| 2450 | + echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>"; |
|
| 2451 | + $arguments_raw = $this->get_arguments(); |
|
| 2452 | + |
|
| 2453 | + if ( is_array( $arguments_raw ) ) { |
|
| 2454 | + |
|
| 2455 | + $arguments = $this->group_arguments( $arguments_raw ); |
|
| 2456 | + |
|
| 2457 | + // Do we have sections? |
|
| 2458 | + $has_sections = $arguments == $arguments_raw ? false : true; |
|
| 2459 | + |
|
| 2460 | + |
|
| 2461 | + if ( $has_sections ) { |
|
| 2462 | + $panel_count = 0; |
|
| 2463 | + foreach ( $arguments as $key => $args ) { |
|
| 2464 | + |
|
| 2465 | + ?> |
|
| 2466 | 2466 | <script> |
| 2467 | 2467 | // jQuery(this).find("i").toggleClass("fas fa-chevron-up fas fa-chevron-down");jQuery(this).next().toggle(); |
| 2468 | 2468 | </script> |
| 2469 | 2469 | <?php |
| 2470 | 2470 | |
| 2471 | - $hide = $panel_count ? ' style="display:none;" ' : ''; |
|
| 2472 | - $icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down'; |
|
| 2473 | - echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes( $key ) . "'>" . esc_attr( $key ) . " <i style='float:right;' class='" . $icon_class . "'></i></button>"; |
|
| 2474 | - echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>"; |
|
| 2475 | - |
|
| 2476 | - foreach ( $args as $k => $a ) { |
|
| 2477 | - $this->widget_inputs( $a, $instance ); |
|
| 2478 | - } |
|
| 2479 | - |
|
| 2480 | - echo "</div>"; |
|
| 2481 | - |
|
| 2482 | - $panel_count ++; |
|
| 2483 | - |
|
| 2484 | - } |
|
| 2485 | - } else { |
|
| 2486 | - foreach ( $arguments as $key => $args ) { |
|
| 2487 | - $this->widget_inputs( $args, $instance ); |
|
| 2488 | - } |
|
| 2489 | - } |
|
| 2490 | - |
|
| 2491 | - } |
|
| 2492 | - } |
|
| 2493 | - |
|
| 2494 | - /** |
|
| 2495 | - * Get the hidden input that when added makes the advanced button show on widget settings. |
|
| 2496 | - * |
|
| 2497 | - * @return string |
|
| 2498 | - */ |
|
| 2499 | - public function widget_advanced_toggle() { |
|
| 2500 | - |
|
| 2501 | - $output = ''; |
|
| 2502 | - if ( $this->block_show_advanced() ) { |
|
| 2503 | - $val = 1; |
|
| 2504 | - } else { |
|
| 2505 | - $val = 0; |
|
| 2506 | - } |
|
| 2507 | - |
|
| 2508 | - $output .= "<input type='hidden' class='sd-show-advanced' value='$val' />"; |
|
| 2509 | - |
|
| 2510 | - return $output; |
|
| 2511 | - } |
|
| 2512 | - |
|
| 2513 | - /** |
|
| 2514 | - * Convert require element. |
|
| 2515 | - * |
|
| 2516 | - * @since 1.0.0 |
|
| 2517 | - * |
|
| 2518 | - * @param string $input Input element. |
|
| 2519 | - * |
|
| 2520 | - * @return string $output |
|
| 2521 | - */ |
|
| 2522 | - public function convert_element_require( $input ) { |
|
| 2523 | - |
|
| 2524 | - $input = str_replace( "'", '"', $input );// we only want double quotes |
|
| 2525 | - |
|
| 2526 | - $output = esc_attr( str_replace( array( "[%", "%]" ), array( |
|
| 2527 | - "jQuery(form).find('[data-argument=\"", |
|
| 2528 | - "\"]').find('input,select,textarea').val()" |
|
| 2529 | - ), $input ) ); |
|
| 2530 | - |
|
| 2531 | - return $output; |
|
| 2532 | - } |
|
| 2533 | - |
|
| 2534 | - /** |
|
| 2535 | - * Builds the inputs for the widget options. |
|
| 2536 | - * |
|
| 2537 | - * @param $args |
|
| 2538 | - * @param $instance |
|
| 2539 | - */ |
|
| 2540 | - public function widget_inputs( $args, $instance ) { |
|
| 2541 | - |
|
| 2542 | - $class = ""; |
|
| 2543 | - $element_require = ""; |
|
| 2544 | - $custom_attributes = ""; |
|
| 2545 | - |
|
| 2546 | - // get value |
|
| 2547 | - if ( isset( $instance[ $args['name'] ] ) ) { |
|
| 2548 | - $value = $instance[ $args['name'] ]; |
|
| 2549 | - } elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) { |
|
| 2550 | - $value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] ); |
|
| 2551 | - } else { |
|
| 2552 | - $value = ''; |
|
| 2553 | - } |
|
| 2554 | - |
|
| 2555 | - // get placeholder |
|
| 2556 | - if ( ! empty( $args['placeholder'] ) ) { |
|
| 2557 | - $placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'"; |
|
| 2558 | - } else { |
|
| 2559 | - $placeholder = ''; |
|
| 2560 | - } |
|
| 2561 | - |
|
| 2562 | - // get if advanced |
|
| 2563 | - if ( isset( $args['advanced'] ) && $args['advanced'] ) { |
|
| 2564 | - $class .= " sd-advanced-setting "; |
|
| 2565 | - } |
|
| 2566 | - |
|
| 2567 | - // element_require |
|
| 2568 | - if ( isset( $args['element_require'] ) && $args['element_require'] ) { |
|
| 2569 | - $element_require = $args['element_require']; |
|
| 2570 | - } |
|
| 2571 | - |
|
| 2572 | - // custom_attributes |
|
| 2573 | - if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) { |
|
| 2574 | - $custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true ); |
|
| 2575 | - } |
|
| 2576 | - |
|
| 2577 | - // before wrapper |
|
| 2578 | - ?> |
|
| 2471 | + $hide = $panel_count ? ' style="display:none;" ' : ''; |
|
| 2472 | + $icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down'; |
|
| 2473 | + echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes( $key ) . "'>" . esc_attr( $key ) . " <i style='float:right;' class='" . $icon_class . "'></i></button>"; |
|
| 2474 | + echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>"; |
|
| 2475 | + |
|
| 2476 | + foreach ( $args as $k => $a ) { |
|
| 2477 | + $this->widget_inputs( $a, $instance ); |
|
| 2478 | + } |
|
| 2479 | + |
|
| 2480 | + echo "</div>"; |
|
| 2481 | + |
|
| 2482 | + $panel_count ++; |
|
| 2483 | + |
|
| 2484 | + } |
|
| 2485 | + } else { |
|
| 2486 | + foreach ( $arguments as $key => $args ) { |
|
| 2487 | + $this->widget_inputs( $args, $instance ); |
|
| 2488 | + } |
|
| 2489 | + } |
|
| 2490 | + |
|
| 2491 | + } |
|
| 2492 | + } |
|
| 2493 | + |
|
| 2494 | + /** |
|
| 2495 | + * Get the hidden input that when added makes the advanced button show on widget settings. |
|
| 2496 | + * |
|
| 2497 | + * @return string |
|
| 2498 | + */ |
|
| 2499 | + public function widget_advanced_toggle() { |
|
| 2500 | + |
|
| 2501 | + $output = ''; |
|
| 2502 | + if ( $this->block_show_advanced() ) { |
|
| 2503 | + $val = 1; |
|
| 2504 | + } else { |
|
| 2505 | + $val = 0; |
|
| 2506 | + } |
|
| 2507 | + |
|
| 2508 | + $output .= "<input type='hidden' class='sd-show-advanced' value='$val' />"; |
|
| 2509 | + |
|
| 2510 | + return $output; |
|
| 2511 | + } |
|
| 2512 | + |
|
| 2513 | + /** |
|
| 2514 | + * Convert require element. |
|
| 2515 | + * |
|
| 2516 | + * @since 1.0.0 |
|
| 2517 | + * |
|
| 2518 | + * @param string $input Input element. |
|
| 2519 | + * |
|
| 2520 | + * @return string $output |
|
| 2521 | + */ |
|
| 2522 | + public function convert_element_require( $input ) { |
|
| 2523 | + |
|
| 2524 | + $input = str_replace( "'", '"', $input );// we only want double quotes |
|
| 2525 | + |
|
| 2526 | + $output = esc_attr( str_replace( array( "[%", "%]" ), array( |
|
| 2527 | + "jQuery(form).find('[data-argument=\"", |
|
| 2528 | + "\"]').find('input,select,textarea').val()" |
|
| 2529 | + ), $input ) ); |
|
| 2530 | + |
|
| 2531 | + return $output; |
|
| 2532 | + } |
|
| 2533 | + |
|
| 2534 | + /** |
|
| 2535 | + * Builds the inputs for the widget options. |
|
| 2536 | + * |
|
| 2537 | + * @param $args |
|
| 2538 | + * @param $instance |
|
| 2539 | + */ |
|
| 2540 | + public function widget_inputs( $args, $instance ) { |
|
| 2541 | + |
|
| 2542 | + $class = ""; |
|
| 2543 | + $element_require = ""; |
|
| 2544 | + $custom_attributes = ""; |
|
| 2545 | + |
|
| 2546 | + // get value |
|
| 2547 | + if ( isset( $instance[ $args['name'] ] ) ) { |
|
| 2548 | + $value = $instance[ $args['name'] ]; |
|
| 2549 | + } elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) { |
|
| 2550 | + $value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] ); |
|
| 2551 | + } else { |
|
| 2552 | + $value = ''; |
|
| 2553 | + } |
|
| 2554 | + |
|
| 2555 | + // get placeholder |
|
| 2556 | + if ( ! empty( $args['placeholder'] ) ) { |
|
| 2557 | + $placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'"; |
|
| 2558 | + } else { |
|
| 2559 | + $placeholder = ''; |
|
| 2560 | + } |
|
| 2561 | + |
|
| 2562 | + // get if advanced |
|
| 2563 | + if ( isset( $args['advanced'] ) && $args['advanced'] ) { |
|
| 2564 | + $class .= " sd-advanced-setting "; |
|
| 2565 | + } |
|
| 2566 | + |
|
| 2567 | + // element_require |
|
| 2568 | + if ( isset( $args['element_require'] ) && $args['element_require'] ) { |
|
| 2569 | + $element_require = $args['element_require']; |
|
| 2570 | + } |
|
| 2571 | + |
|
| 2572 | + // custom_attributes |
|
| 2573 | + if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) { |
|
| 2574 | + $custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true ); |
|
| 2575 | + } |
|
| 2576 | + |
|
| 2577 | + // before wrapper |
|
| 2578 | + ?> |
|
| 2579 | 2579 | <p class="sd-argument <?php echo esc_attr( $class ); ?>" |
| 2580 | 2580 | data-argument='<?php echo esc_attr( $args['name'] ); ?>' |
| 2581 | 2581 | data-element_require='<?php if ( $element_require ) { |
| 2582 | - echo $this->convert_element_require( $element_require ); |
|
| 2583 | - } ?>' |
|
| 2582 | + echo $this->convert_element_require( $element_require ); |
|
| 2583 | + } ?>' |
|
| 2584 | 2584 | > |
| 2585 | 2585 | <?php |
| 2586 | 2586 | |
| 2587 | - switch ( $args['type'] ) { |
|
| 2588 | - //array('text','password','number','email','tel','url','color') |
|
| 2589 | - case "text": |
|
| 2590 | - case "password": |
|
| 2591 | - case "number": |
|
| 2592 | - case "email": |
|
| 2593 | - case "tel": |
|
| 2594 | - case "url": |
|
| 2595 | - case "color": |
|
| 2596 | - ?> |
|
| 2587 | + switch ( $args['type'] ) { |
|
| 2588 | + //array('text','password','number','email','tel','url','color') |
|
| 2589 | + case "text": |
|
| 2590 | + case "password": |
|
| 2591 | + case "number": |
|
| 2592 | + case "email": |
|
| 2593 | + case "tel": |
|
| 2594 | + case "url": |
|
| 2595 | + case "color": |
|
| 2596 | + ?> |
|
| 2597 | 2597 | <label |
| 2598 | 2598 | for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label> |
| 2599 | 2599 | <input <?php echo $placeholder; ?> class="widefat" |
@@ -2604,47 +2604,47 @@ discard block |
||
| 2604 | 2604 | value="<?php echo esc_attr( $value ); ?>"> |
| 2605 | 2605 | <?php |
| 2606 | 2606 | |
| 2607 | - break; |
|
| 2608 | - case "select": |
|
| 2609 | - $multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false; |
|
| 2610 | - if ( $multiple ) { |
|
| 2611 | - if ( empty( $value ) ) { |
|
| 2612 | - $value = array(); |
|
| 2613 | - } |
|
| 2614 | - } |
|
| 2615 | - ?> |
|
| 2607 | + break; |
|
| 2608 | + case "select": |
|
| 2609 | + $multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false; |
|
| 2610 | + if ( $multiple ) { |
|
| 2611 | + if ( empty( $value ) ) { |
|
| 2612 | + $value = array(); |
|
| 2613 | + } |
|
| 2614 | + } |
|
| 2615 | + ?> |
|
| 2616 | 2616 | <label |
| 2617 | 2617 | for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label> |
| 2618 | 2618 | <select <?php echo $placeholder; ?> class="widefat" |
| 2619 | 2619 | <?php echo $custom_attributes; ?> |
| 2620 | 2620 | id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
| 2621 | 2621 | name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); |
| 2622 | - if ( $multiple ) { |
|
| 2623 | - echo "[]"; |
|
| 2624 | - } ?>" |
|
| 2622 | + if ( $multiple ) { |
|
| 2623 | + echo "[]"; |
|
| 2624 | + } ?>" |
|
| 2625 | 2625 | <?php if ( $multiple ) { |
| 2626 | - echo "multiple"; |
|
| 2627 | - } //@todo not implemented yet due to gutenberg not supporting it |
|
| 2628 | - ?> |
|
| 2626 | + echo "multiple"; |
|
| 2627 | + } //@todo not implemented yet due to gutenberg not supporting it |
|
| 2628 | + ?> |
|
| 2629 | 2629 | > |
| 2630 | 2630 | <?php |
| 2631 | 2631 | |
| 2632 | - if ( ! empty( $args['options'] ) ) { |
|
| 2633 | - foreach ( $args['options'] as $val => $label ) { |
|
| 2634 | - if ( $multiple ) { |
|
| 2635 | - $selected = in_array( $val, $value ) ? 'selected="selected"' : ''; |
|
| 2636 | - } else { |
|
| 2637 | - $selected = selected( $value, $val, false ); |
|
| 2638 | - } |
|
| 2639 | - echo "<option value='$val' " . $selected . ">$label</option>"; |
|
| 2640 | - } |
|
| 2641 | - } |
|
| 2642 | - ?> |
|
| 2632 | + if ( ! empty( $args['options'] ) ) { |
|
| 2633 | + foreach ( $args['options'] as $val => $label ) { |
|
| 2634 | + if ( $multiple ) { |
|
| 2635 | + $selected = in_array( $val, $value ) ? 'selected="selected"' : ''; |
|
| 2636 | + } else { |
|
| 2637 | + $selected = selected( $value, $val, false ); |
|
| 2638 | + } |
|
| 2639 | + echo "<option value='$val' " . $selected . ">$label</option>"; |
|
| 2640 | + } |
|
| 2641 | + } |
|
| 2642 | + ?> |
|
| 2643 | 2643 | </select> |
| 2644 | 2644 | <?php |
| 2645 | - break; |
|
| 2646 | - case "checkbox": |
|
| 2647 | - ?> |
|
| 2645 | + break; |
|
| 2646 | + case "checkbox": |
|
| 2647 | + ?> |
|
| 2648 | 2648 | <input <?php echo $placeholder; ?> |
| 2649 | 2649 | <?php checked( 1, $value, true ) ?> |
| 2650 | 2650 | <?php echo $custom_attributes; ?> |
@@ -2654,9 +2654,9 @@ discard block |
||
| 2654 | 2654 | <label |
| 2655 | 2655 | for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label> |
| 2656 | 2656 | <?php |
| 2657 | - break; |
|
| 2658 | - case "textarea": |
|
| 2659 | - ?> |
|
| 2657 | + break; |
|
| 2658 | + case "textarea": |
|
| 2659 | + ?> |
|
| 2660 | 2660 | <label |
| 2661 | 2661 | for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label> |
| 2662 | 2662 | <textarea <?php echo $placeholder; ?> class="widefat" |
@@ -2666,136 +2666,136 @@ discard block |
||
| 2666 | 2666 | ><?php echo esc_attr( $value ); ?></textarea> |
| 2667 | 2667 | <?php |
| 2668 | 2668 | |
| 2669 | - break; |
|
| 2670 | - case "hidden": |
|
| 2671 | - ?> |
|
| 2669 | + break; |
|
| 2670 | + case "hidden": |
|
| 2671 | + ?> |
|
| 2672 | 2672 | <input id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
| 2673 | 2673 | name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="hidden" |
| 2674 | 2674 | value="<?php echo esc_attr( $value ); ?>"> |
| 2675 | 2675 | <?php |
| 2676 | - break; |
|
| 2677 | - default: |
|
| 2678 | - echo "No input type found!"; // @todo we need to add more input types. |
|
| 2679 | - } |
|
| 2676 | + break; |
|
| 2677 | + default: |
|
| 2678 | + echo "No input type found!"; // @todo we need to add more input types. |
|
| 2679 | + } |
|
| 2680 | 2680 | |
| 2681 | - // after wrapper |
|
| 2682 | - ?> |
|
| 2681 | + // after wrapper |
|
| 2682 | + ?> |
|
| 2683 | 2683 | </p> |
| 2684 | 2684 | <?php |
| 2685 | 2685 | |
| 2686 | - } |
|
| 2687 | - |
|
| 2688 | - /** |
|
| 2689 | - * Get the widget input description html. |
|
| 2690 | - * |
|
| 2691 | - * @param $args |
|
| 2692 | - * |
|
| 2693 | - * @return string |
|
| 2694 | - * @todo, need to make its own tooltip script |
|
| 2695 | - */ |
|
| 2696 | - public function widget_field_desc( $args ) { |
|
| 2697 | - |
|
| 2698 | - $description = ''; |
|
| 2699 | - if ( isset( $args['desc'] ) && $args['desc'] ) { |
|
| 2700 | - if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) { |
|
| 2701 | - $description = $this->desc_tip( $args['desc'] ); |
|
| 2702 | - } else { |
|
| 2703 | - $description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>'; |
|
| 2704 | - } |
|
| 2705 | - } |
|
| 2706 | - |
|
| 2707 | - return $description; |
|
| 2708 | - } |
|
| 2709 | - |
|
| 2710 | - /** |
|
| 2711 | - * Get the tool tip html. |
|
| 2712 | - * |
|
| 2713 | - * @param $tip |
|
| 2714 | - * @param bool $allow_html |
|
| 2715 | - * |
|
| 2716 | - * @return string |
|
| 2717 | - */ |
|
| 2718 | - function desc_tip( $tip, $allow_html = false ) { |
|
| 2719 | - if ( $allow_html ) { |
|
| 2720 | - $tip = $this->sanitize_tooltip( $tip ); |
|
| 2721 | - } else { |
|
| 2722 | - $tip = esc_attr( $tip ); |
|
| 2723 | - } |
|
| 2724 | - |
|
| 2725 | - return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
|
| 2726 | - } |
|
| 2727 | - |
|
| 2728 | - /** |
|
| 2729 | - * Sanitize a string destined to be a tooltip. |
|
| 2730 | - * |
|
| 2731 | - * @param string $var |
|
| 2732 | - * |
|
| 2733 | - * @return string |
|
| 2734 | - */ |
|
| 2735 | - public function sanitize_tooltip( $var ) { |
|
| 2736 | - return htmlspecialchars( wp_kses( html_entity_decode( $var ), array( |
|
| 2737 | - 'br' => array(), |
|
| 2738 | - 'em' => array(), |
|
| 2739 | - 'strong' => array(), |
|
| 2740 | - 'small' => array(), |
|
| 2741 | - 'span' => array(), |
|
| 2742 | - 'ul' => array(), |
|
| 2743 | - 'li' => array(), |
|
| 2744 | - 'ol' => array(), |
|
| 2745 | - 'p' => array(), |
|
| 2746 | - ) ) ); |
|
| 2747 | - } |
|
| 2748 | - |
|
| 2749 | - /** |
|
| 2750 | - * Processing widget options on save |
|
| 2751 | - * |
|
| 2752 | - * @param array $new_instance The new options |
|
| 2753 | - * @param array $old_instance The previous options |
|
| 2754 | - * |
|
| 2755 | - * @return array |
|
| 2756 | - * @todo we should add some sanitation here. |
|
| 2757 | - */ |
|
| 2758 | - public function update( $new_instance, $old_instance ) { |
|
| 2759 | - |
|
| 2760 | - //save the widget |
|
| 2761 | - $instance = array_merge( (array) $old_instance, (array) $new_instance ); |
|
| 2762 | - |
|
| 2763 | - // set widget instance |
|
| 2764 | - $this->instance = $instance; |
|
| 2765 | - |
|
| 2766 | - if ( empty( $this->arguments ) ) { |
|
| 2767 | - $this->get_arguments(); |
|
| 2768 | - } |
|
| 2769 | - |
|
| 2770 | - // check for checkboxes |
|
| 2771 | - if ( ! empty( $this->arguments ) ) { |
|
| 2772 | - foreach ( $this->arguments as $argument ) { |
|
| 2773 | - if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) { |
|
| 2774 | - $instance[ $argument['name'] ] = '0'; |
|
| 2775 | - } |
|
| 2776 | - } |
|
| 2777 | - } |
|
| 2778 | - |
|
| 2779 | - return $instance; |
|
| 2780 | - } |
|
| 2781 | - |
|
| 2782 | - /** |
|
| 2783 | - * Checks if the current call is a ajax call to get the block content. |
|
| 2784 | - * |
|
| 2785 | - * This can be used in your widget to return different content as the block content. |
|
| 2786 | - * |
|
| 2787 | - * @since 1.0.3 |
|
| 2788 | - * @return bool |
|
| 2789 | - */ |
|
| 2790 | - public function is_block_content_call() { |
|
| 2791 | - $result = false; |
|
| 2792 | - if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) { |
|
| 2793 | - $result = true; |
|
| 2794 | - } |
|
| 2795 | - |
|
| 2796 | - return $result; |
|
| 2797 | - } |
|
| 2798 | - |
|
| 2799 | - } |
|
| 2686 | + } |
|
| 2687 | + |
|
| 2688 | + /** |
|
| 2689 | + * Get the widget input description html. |
|
| 2690 | + * |
|
| 2691 | + * @param $args |
|
| 2692 | + * |
|
| 2693 | + * @return string |
|
| 2694 | + * @todo, need to make its own tooltip script |
|
| 2695 | + */ |
|
| 2696 | + public function widget_field_desc( $args ) { |
|
| 2697 | + |
|
| 2698 | + $description = ''; |
|
| 2699 | + if ( isset( $args['desc'] ) && $args['desc'] ) { |
|
| 2700 | + if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) { |
|
| 2701 | + $description = $this->desc_tip( $args['desc'] ); |
|
| 2702 | + } else { |
|
| 2703 | + $description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>'; |
|
| 2704 | + } |
|
| 2705 | + } |
|
| 2706 | + |
|
| 2707 | + return $description; |
|
| 2708 | + } |
|
| 2709 | + |
|
| 2710 | + /** |
|
| 2711 | + * Get the tool tip html. |
|
| 2712 | + * |
|
| 2713 | + * @param $tip |
|
| 2714 | + * @param bool $allow_html |
|
| 2715 | + * |
|
| 2716 | + * @return string |
|
| 2717 | + */ |
|
| 2718 | + function desc_tip( $tip, $allow_html = false ) { |
|
| 2719 | + if ( $allow_html ) { |
|
| 2720 | + $tip = $this->sanitize_tooltip( $tip ); |
|
| 2721 | + } else { |
|
| 2722 | + $tip = esc_attr( $tip ); |
|
| 2723 | + } |
|
| 2724 | + |
|
| 2725 | + return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
|
| 2726 | + } |
|
| 2727 | + |
|
| 2728 | + /** |
|
| 2729 | + * Sanitize a string destined to be a tooltip. |
|
| 2730 | + * |
|
| 2731 | + * @param string $var |
|
| 2732 | + * |
|
| 2733 | + * @return string |
|
| 2734 | + */ |
|
| 2735 | + public function sanitize_tooltip( $var ) { |
|
| 2736 | + return htmlspecialchars( wp_kses( html_entity_decode( $var ), array( |
|
| 2737 | + 'br' => array(), |
|
| 2738 | + 'em' => array(), |
|
| 2739 | + 'strong' => array(), |
|
| 2740 | + 'small' => array(), |
|
| 2741 | + 'span' => array(), |
|
| 2742 | + 'ul' => array(), |
|
| 2743 | + 'li' => array(), |
|
| 2744 | + 'ol' => array(), |
|
| 2745 | + 'p' => array(), |
|
| 2746 | + ) ) ); |
|
| 2747 | + } |
|
| 2748 | + |
|
| 2749 | + /** |
|
| 2750 | + * Processing widget options on save |
|
| 2751 | + * |
|
| 2752 | + * @param array $new_instance The new options |
|
| 2753 | + * @param array $old_instance The previous options |
|
| 2754 | + * |
|
| 2755 | + * @return array |
|
| 2756 | + * @todo we should add some sanitation here. |
|
| 2757 | + */ |
|
| 2758 | + public function update( $new_instance, $old_instance ) { |
|
| 2759 | + |
|
| 2760 | + //save the widget |
|
| 2761 | + $instance = array_merge( (array) $old_instance, (array) $new_instance ); |
|
| 2762 | + |
|
| 2763 | + // set widget instance |
|
| 2764 | + $this->instance = $instance; |
|
| 2765 | + |
|
| 2766 | + if ( empty( $this->arguments ) ) { |
|
| 2767 | + $this->get_arguments(); |
|
| 2768 | + } |
|
| 2769 | + |
|
| 2770 | + // check for checkboxes |
|
| 2771 | + if ( ! empty( $this->arguments ) ) { |
|
| 2772 | + foreach ( $this->arguments as $argument ) { |
|
| 2773 | + if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) { |
|
| 2774 | + $instance[ $argument['name'] ] = '0'; |
|
| 2775 | + } |
|
| 2776 | + } |
|
| 2777 | + } |
|
| 2778 | + |
|
| 2779 | + return $instance; |
|
| 2780 | + } |
|
| 2781 | + |
|
| 2782 | + /** |
|
| 2783 | + * Checks if the current call is a ajax call to get the block content. |
|
| 2784 | + * |
|
| 2785 | + * This can be used in your widget to return different content as the block content. |
|
| 2786 | + * |
|
| 2787 | + * @since 1.0.3 |
|
| 2788 | + * @return bool |
|
| 2789 | + */ |
|
| 2790 | + public function is_block_content_call() { |
|
| 2791 | + $result = false; |
|
| 2792 | + if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) { |
|
| 2793 | + $result = true; |
|
| 2794 | + } |
|
| 2795 | + |
|
| 2796 | + return $result; |
|
| 2797 | + } |
|
| 2798 | + |
|
| 2799 | + } |
|
| 2800 | 2800 | |
| 2801 | 2801 | } |
| 2802 | 2802 | \ No newline at end of file |
@@ -1,9 +1,9 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if (!defined('ABSPATH')) { |
|
| 3 | 3 | exit; |
| 4 | 4 | } |
| 5 | 5 | |
| 6 | -if ( ! class_exists( 'WP_Super_Duper' ) ) { |
|
| 6 | +if (!class_exists('WP_Super_Duper')) { |
|
| 7 | 7 | |
| 8 | 8 | |
| 9 | 9 | /** |
@@ -36,27 +36,27 @@ discard block |
||
| 36 | 36 | /** |
| 37 | 37 | * Take the array options and use them to build. |
| 38 | 38 | */ |
| 39 | - public function __construct( $options ) { |
|
| 39 | + public function __construct($options) { |
|
| 40 | 40 | global $sd_widgets; |
| 41 | 41 | |
| 42 | - $sd_widgets[ $options['base_id'] ] = array( |
|
| 42 | + $sd_widgets[$options['base_id']] = array( |
|
| 43 | 43 | 'name' => $options['name'], |
| 44 | 44 | 'class_name' => $options['class_name'] |
| 45 | 45 | ); |
| 46 | - $this->base_id = $options['base_id']; |
|
| 46 | + $this->base_id = $options['base_id']; |
|
| 47 | 47 | // lets filter the options before we do anything |
| 48 | - $options = apply_filters( "wp_super_duper_options", $options ); |
|
| 49 | - $options = apply_filters( "wp_super_duper_options_{$this->base_id}", $options ); |
|
| 50 | - $options = $this->add_name_from_key( $options ); |
|
| 48 | + $options = apply_filters("wp_super_duper_options", $options); |
|
| 49 | + $options = apply_filters("wp_super_duper_options_{$this->base_id}", $options); |
|
| 50 | + $options = $this->add_name_from_key($options); |
|
| 51 | 51 | $this->options = $options; |
| 52 | 52 | |
| 53 | 53 | $this->base_id = $options['base_id']; |
| 54 | - $this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array(); |
|
| 54 | + $this->arguments = isset($options['arguments']) ? $options['arguments'] : array(); |
|
| 55 | 55 | |
| 56 | 56 | // init parent |
| 57 | - parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] ); |
|
| 57 | + parent::__construct($options['base_id'], $options['name'], $options['widget_ops']); |
|
| 58 | 58 | |
| 59 | - if ( isset( $options['class_name'] ) ) { |
|
| 59 | + if (isset($options['class_name'])) { |
|
| 60 | 60 | // register widget |
| 61 | 61 | $this->class_name = $options['class_name']; |
| 62 | 62 | |
@@ -64,66 +64,66 @@ discard block |
||
| 64 | 64 | $this->register_shortcode(); |
| 65 | 65 | |
| 66 | 66 | // Fusion Builder (avada) support |
| 67 | - if ( function_exists( 'fusion_builder_map' ) ) { |
|
| 68 | - add_action( 'init', array( $this, 'register_fusion_element' ) ); |
|
| 67 | + if (function_exists('fusion_builder_map')) { |
|
| 68 | + add_action('init', array($this, 'register_fusion_element')); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | // register block |
| 72 | - add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) ); |
|
| 72 | + add_action('admin_enqueue_scripts', array($this, 'register_block')); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | // add the CSS and JS we need ONCE |
| 76 | 76 | global $sd_widget_scripts; |
| 77 | 77 | |
| 78 | - if ( ! $sd_widget_scripts ) { |
|
| 79 | - wp_add_inline_script( 'admin-widgets', $this->widget_js() ); |
|
| 80 | - wp_add_inline_script( 'customize-controls', $this->widget_js() ); |
|
| 81 | - wp_add_inline_style( 'widgets', $this->widget_css() ); |
|
| 78 | + if (!$sd_widget_scripts) { |
|
| 79 | + wp_add_inline_script('admin-widgets', $this->widget_js()); |
|
| 80 | + wp_add_inline_script('customize-controls', $this->widget_js()); |
|
| 81 | + wp_add_inline_style('widgets', $this->widget_css()); |
|
| 82 | 82 | |
| 83 | 83 | // maybe add elementor editor styles |
| 84 | - add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'elementor_editor_styles' ) ); |
|
| 84 | + add_action('elementor/editor/after_enqueue_styles', array($this, 'elementor_editor_styles')); |
|
| 85 | 85 | |
| 86 | 86 | $sd_widget_scripts = true; |
| 87 | 87 | |
| 88 | 88 | // add shortcode insert button once |
| 89 | - add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) ); |
|
| 89 | + add_action('media_buttons', array($this, 'shortcode_insert_button')); |
|
| 90 | 90 | // generatepress theme sections compatibility |
| 91 | - if ( function_exists( 'generate_sections_sections_metabox' ) ) { |
|
| 92 | - add_action( 'generate_sections_metabox', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 91 | + if (function_exists('generate_sections_sections_metabox')) { |
|
| 92 | + add_action('generate_sections_metabox', array($this, 'shortcode_insert_button_script')); |
|
| 93 | 93 | } |
| 94 | - if ( $this->is_preview() ) { |
|
| 95 | - add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) ); |
|
| 94 | + if ($this->is_preview()) { |
|
| 95 | + add_action('wp_footer', array($this, 'shortcode_insert_button_script')); |
|
| 96 | 96 | // this makes the insert button work for elementor |
| 97 | - add_action( 'elementor/editor/after_enqueue_scripts', array( |
|
| 97 | + add_action('elementor/editor/after_enqueue_scripts', array( |
|
| 98 | 98 | $this, |
| 99 | 99 | 'shortcode_insert_button_script' |
| 100 | - ) ); // for elementor |
|
| 100 | + )); // for elementor |
|
| 101 | 101 | } |
| 102 | 102 | // this makes the insert button work for cornerstone |
| 103 | - add_action( 'wp_print_footer_scripts', array( __CLASS__, 'maybe_cornerstone_builder' ) ); |
|
| 103 | + add_action('wp_print_footer_scripts', array(__CLASS__, 'maybe_cornerstone_builder')); |
|
| 104 | 104 | |
| 105 | - add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) ); |
|
| 106 | - add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) ); |
|
| 105 | + add_action('wp_ajax_super_duper_get_widget_settings', array(__CLASS__, 'get_widget_settings')); |
|
| 106 | + add_action('wp_ajax_super_duper_get_picker', array(__CLASS__, 'get_picker')); |
|
| 107 | 107 | |
| 108 | 108 | // add generator text to admin head |
| 109 | - add_action( 'admin_head', array( $this, 'generator' ) ); |
|
| 109 | + add_action('admin_head', array($this, 'generator')); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - do_action( 'wp_super_duper_widget_init', $options, $this ); |
|
| 112 | + do_action('wp_super_duper_widget_init', $options, $this); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
| 116 | 116 | * Add our widget CSS to elementor editor. |
| 117 | 117 | */ |
| 118 | 118 | public function elementor_editor_styles() { |
| 119 | - wp_add_inline_style( 'elementor-editor', $this->widget_css( false ) ); |
|
| 119 | + wp_add_inline_style('elementor-editor', $this->widget_css(false)); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | public function register_fusion_element() { |
| 123 | 123 | |
| 124 | 124 | $options = $this->options; |
| 125 | 125 | |
| 126 | - if ( $this->base_id ) { |
|
| 126 | + if ($this->base_id) { |
|
| 127 | 127 | |
| 128 | 128 | $params = $this->get_fusion_params(); |
| 129 | 129 | |
@@ -134,11 +134,11 @@ discard block |
||
| 134 | 134 | 'allow_generator' => true, |
| 135 | 135 | ); |
| 136 | 136 | |
| 137 | - if ( ! empty( $params ) ) { |
|
| 137 | + if (!empty($params)) { |
|
| 138 | 138 | $args['params'] = $params; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - fusion_builder_map( $args ); |
|
| 141 | + fusion_builder_map($args); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | } |
@@ -147,8 +147,8 @@ discard block |
||
| 147 | 147 | $params = array(); |
| 148 | 148 | $arguments = $this->get_arguments(); |
| 149 | 149 | |
| 150 | - if ( ! empty( $arguments ) ) { |
|
| 151 | - foreach ( $arguments as $key => $val ) { |
|
| 150 | + if (!empty($arguments)) { |
|
| 151 | + foreach ($arguments as $key => $val) { |
|
| 152 | 152 | $param = array(); |
| 153 | 153 | // type |
| 154 | 154 | $param['type'] = str_replace( |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | $val['type'] ); |
| 171 | 171 | |
| 172 | 172 | // multiselect |
| 173 | - if ( $val['type'] == 'multiselect' || ( ( $param['type'] == 'select' || $val['type'] == 'select' ) && ! empty( $val['multiple'] ) ) ) { |
|
| 173 | + if ($val['type'] == 'multiselect' || (($param['type'] == 'select' || $val['type'] == 'select') && !empty($val['multiple']))) { |
|
| 174 | 174 | $param['type'] = 'multiple_select'; |
| 175 | 175 | $param['multiple'] = true; |
| 176 | 176 | } |
@@ -179,29 +179,29 @@ discard block |
||
| 179 | 179 | $param['heading'] = $val['title']; |
| 180 | 180 | |
| 181 | 181 | // description |
| 182 | - $param['description'] = isset( $val['desc'] ) ? $val['desc'] : ''; |
|
| 182 | + $param['description'] = isset($val['desc']) ? $val['desc'] : ''; |
|
| 183 | 183 | |
| 184 | 184 | // param_name |
| 185 | 185 | $param['param_name'] = $key; |
| 186 | 186 | |
| 187 | 187 | // Default |
| 188 | - $param['default'] = isset( $val['default'] ) ? $val['default'] : ''; |
|
| 188 | + $param['default'] = isset($val['default']) ? $val['default'] : ''; |
|
| 189 | 189 | |
| 190 | 190 | // Group |
| 191 | - if ( isset( $val['group'] ) ) { |
|
| 191 | + if (isset($val['group'])) { |
|
| 192 | 192 | $param['group'] = $val['group']; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | // value |
| 196 | - if ( $val['type'] == 'checkbox' ) { |
|
| 197 | - if ( isset( $val['default'] ) && $val['default'] == '0' ) { |
|
| 198 | - unset( $param['default'] ); |
|
| 196 | + if ($val['type'] == 'checkbox') { |
|
| 197 | + if (isset($val['default']) && $val['default'] == '0') { |
|
| 198 | + unset($param['default']); |
|
| 199 | 199 | } |
| 200 | - $param['value'] = array( '' => __( "No" ), '1' => __( "Yes" ) ); |
|
| 201 | - } elseif ( $param['type'] == 'select' || $param['type'] == 'multiple_select' ) { |
|
| 202 | - $param['value'] = isset( $val['options'] ) ? $val['options'] : array(); |
|
| 200 | + $param['value'] = array('' => __("No"), '1' => __("Yes")); |
|
| 201 | + } elseif ($param['type'] == 'select' || $param['type'] == 'multiple_select') { |
|
| 202 | + $param['value'] = isset($val['options']) ? $val['options'] : array(); |
|
| 203 | 203 | } else { |
| 204 | - $param['value'] = isset( $val['default'] ) ? $val['default'] : ''; |
|
| 204 | + $param['value'] = isset($val['default']) ? $val['default'] : ''; |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | // setup the param |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder |
| 219 | 219 | */ |
| 220 | 220 | public static function maybe_cornerstone_builder() { |
| 221 | - if ( did_action( 'cornerstone_before_boot_app' ) ) { |
|
| 221 | + if (did_action('cornerstone_before_boot_app')) { |
|
| 222 | 222 | self::shortcode_insert_button_script(); |
| 223 | 223 | } |
| 224 | 224 | } |
@@ -230,12 +230,12 @@ discard block |
||
| 230 | 230 | * |
| 231 | 231 | * @return string |
| 232 | 232 | */ |
| 233 | - public static function get_picker( $editor_id = '' ) { |
|
| 233 | + public static function get_picker($editor_id = '') { |
|
| 234 | 234 | |
| 235 | 235 | ob_start(); |
| 236 | - if ( isset( $_POST['editor_id'] ) ) { |
|
| 237 | - $editor_id = esc_attr( $_POST['editor_id'] ); |
|
| 238 | - } elseif ( isset( $_REQUEST['et_fb'] ) ) { |
|
| 236 | + if (isset($_POST['editor_id'])) { |
|
| 237 | + $editor_id = esc_attr($_POST['editor_id']); |
|
| 238 | + } elseif (isset($_REQUEST['et_fb'])) { |
|
| 239 | 239 | $editor_id = 'main_content_content_vb_tiny_mce'; |
| 240 | 240 | } |
| 241 | 241 | |
@@ -244,13 +244,13 @@ discard block |
||
| 244 | 244 | |
| 245 | 245 | <div class="sd-shortcode-left-wrap"> |
| 246 | 246 | <?php |
| 247 | - ksort( $sd_widgets ); |
|
| 247 | + ksort($sd_widgets); |
|
| 248 | 248 | // print_r($sd_widgets);exit; |
| 249 | - if ( ! empty( $sd_widgets ) ) { |
|
| 249 | + if (!empty($sd_widgets)) { |
|
| 250 | 250 | echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">'; |
| 251 | - echo "<option>" . __( 'Select shortcode' ) . "</option>"; |
|
| 252 | - foreach ( $sd_widgets as $shortcode => $class ) { |
|
| 253 | - echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>"; |
|
| 251 | + echo "<option>" . __('Select shortcode') . "</option>"; |
|
| 252 | + foreach ($sd_widgets as $shortcode => $class) { |
|
| 253 | + echo "<option value='" . esc_attr($shortcode) . "'>" . esc_attr($shortcode) . " (" . esc_attr($class['name']) . ")</option>"; |
|
| 254 | 254 | } |
| 255 | 255 | echo "</select>"; |
| 256 | 256 | |
@@ -263,37 +263,37 @@ discard block |
||
| 263 | 263 | <div class="sd-shortcode-right-wrap"> |
| 264 | 264 | <textarea id='sd-shortcode-output' disabled></textarea> |
| 265 | 265 | <div id='sd-shortcode-output-actions'> |
| 266 | - <?php if ( $editor_id != '' ) { ?> |
|
| 266 | + <?php if ($editor_id != '') { ?> |
|
| 267 | 267 | <button class="button sd-insert-shortcode-button" |
| 268 | - onclick="sd_insert_shortcode(<?php if ( ! empty( $editor_id ) ) { |
|
| 268 | + onclick="sd_insert_shortcode(<?php if (!empty($editor_id)) { |
|
| 269 | 269 | echo "'" . $editor_id . "'"; |
| 270 | - } ?>)"><?php _e( 'Insert shortcode' ); ?></button> |
|
| 270 | + } ?>)"><?php _e('Insert shortcode'); ?></button> |
|
| 271 | 271 | <?php } ?> |
| 272 | 272 | <button class="button" |
| 273 | - onclick="sd_copy_to_clipboard()"><?php _e( 'Copy shortcode' ); ?></button> |
|
| 273 | + onclick="sd_copy_to_clipboard()"><?php _e('Copy shortcode'); ?></button> |
|
| 274 | 274 | </div> |
| 275 | 275 | </div> |
| 276 | 276 | <?php |
| 277 | 277 | |
| 278 | 278 | $html = ob_get_clean(); |
| 279 | 279 | |
| 280 | - if ( wp_doing_ajax() ) { |
|
| 280 | + if (wp_doing_ajax()) { |
|
| 281 | 281 | echo $html; |
| 282 | 282 | $should_die = true; |
| 283 | 283 | |
| 284 | 284 | // some builder get the editor via ajax so we should not die on those ocasions |
| 285 | 285 | $dont_die = array( |
| 286 | - 'parent_tag',// WP Bakery |
|
| 286 | + 'parent_tag', // WP Bakery |
|
| 287 | 287 | 'avia_request' // enfold |
| 288 | 288 | ); |
| 289 | 289 | |
| 290 | - foreach ( $dont_die as $request ) { |
|
| 291 | - if ( isset( $_REQUEST[ $request ] ) ) { |
|
| 290 | + foreach ($dont_die as $request) { |
|
| 291 | + if (isset($_REQUEST[$request])) { |
|
| 292 | 292 | $should_die = false; |
| 293 | 293 | } |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | - if ( $should_die ) { |
|
| 296 | + if ($should_die) { |
|
| 297 | 297 | wp_die(); |
| 298 | 298 | } |
| 299 | 299 | |
@@ -320,16 +320,16 @@ discard block |
||
| 320 | 320 | public static function get_widget_settings() { |
| 321 | 321 | global $sd_widgets; |
| 322 | 322 | |
| 323 | - $shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : ''; |
|
| 324 | - if ( ! $shortcode ) { |
|
| 323 | + $shortcode = isset($_REQUEST['shortcode']) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes($_REQUEST['shortcode']) : ''; |
|
| 324 | + if (!$shortcode) { |
|
| 325 | 325 | wp_die(); |
| 326 | 326 | } |
| 327 | - $widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : ''; |
|
| 328 | - if ( ! $widget_args ) { |
|
| 327 | + $widget_args = isset($sd_widgets[$shortcode]) ? $sd_widgets[$shortcode] : ''; |
|
| 328 | + if (!$widget_args) { |
|
| 329 | 329 | wp_die(); |
| 330 | 330 | } |
| 331 | - $class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : ''; |
|
| 332 | - if ( ! $class_name ) { |
|
| 331 | + $class_name = isset($widget_args['class_name']) && $widget_args['class_name'] ? $widget_args['class_name'] : ''; |
|
| 332 | + if (!$class_name) { |
|
| 333 | 333 | wp_die(); |
| 334 | 334 | } |
| 335 | 335 | |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | $widget = new $class_name; |
| 338 | 338 | |
| 339 | 339 | ob_start(); |
| 340 | - $widget->form( array() ); |
|
| 340 | + $widget->form(array()); |
|
| 341 | 341 | $form = ob_get_clean(); |
| 342 | 342 | echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>"; |
| 343 | 343 | echo "<style>" . $widget->widget_css() . "</style>"; |
@@ -355,9 +355,9 @@ discard block |
||
| 355 | 355 | * @param string $editor_id Optional. Shortcode editor id. Default null. |
| 356 | 356 | * @param string $insert_shortcode_function Optional. Insert shotcode function. Default null. |
| 357 | 357 | */ |
| 358 | - public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) { |
|
| 358 | + public static function shortcode_insert_button($editor_id = '', $insert_shortcode_function = '') { |
|
| 359 | 359 | global $sd_widgets, $shortcode_insert_button_once; |
| 360 | - if ( $shortcode_insert_button_once ) { |
|
| 360 | + if ($shortcode_insert_button_once) { |
|
| 361 | 361 | return; |
| 362 | 362 | } |
| 363 | 363 | add_thickbox(); |
@@ -367,21 +367,21 @@ discard block |
||
| 367 | 367 | * Cornerstone makes us play dirty tricks :/ |
| 368 | 368 | * All media_buttons are removed via JS unless they are two specific id's so we wrap our content in this ID so it is not removed. |
| 369 | 369 | */ |
| 370 | - if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { |
|
| 370 | + if (function_exists('cornerstone_plugin_init') && !is_admin()) { |
|
| 371 | 371 | echo '<span id="insert-media-button">'; |
| 372 | 372 | } |
| 373 | 373 | |
| 374 | - echo self::shortcode_button( 'this', 'true' ); |
|
| 374 | + echo self::shortcode_button('this', 'true'); |
|
| 375 | 375 | |
| 376 | 376 | // see opening note |
| 377 | - if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { |
|
| 377 | + if (function_exists('cornerstone_plugin_init') && !is_admin()) { |
|
| 378 | 378 | echo '</span>'; // end #insert-media-button |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | // Add separate script for generatepress theme sections |
| 382 | - if ( function_exists( 'generate_sections_sections_metabox' ) && did_action( 'generate_sections_metabox' ) ) { |
|
| 382 | + if (function_exists('generate_sections_sections_metabox') && did_action('generate_sections_metabox')) { |
|
| 383 | 383 | } else { |
| 384 | - self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function ); |
|
| 384 | + self::shortcode_insert_button_script($editor_id, $insert_shortcode_function); |
|
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | $shortcode_insert_button_once = true; |
@@ -395,12 +395,12 @@ discard block |
||
| 395 | 395 | * |
| 396 | 396 | * @return mixed |
| 397 | 397 | */ |
| 398 | - public static function shortcode_button( $id = '', $search_for_id = '' ) { |
|
| 398 | + public static function shortcode_button($id = '', $search_for_id = '') { |
|
| 399 | 399 | ob_start(); |
| 400 | 400 | ?> |
| 401 | 401 | <span class="sd-lable-shortcode-inserter"> |
| 402 | 402 | <a onclick="sd_ajax_get_picker(<?php echo $id; |
| 403 | - if ( $search_for_id ) { |
|
| 403 | + if ($search_for_id) { |
|
| 404 | 404 | echo "," . $search_for_id; |
| 405 | 405 | } ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed" |
| 406 | 406 | class="thickbox button super-duper-content-open" title="Add Shortcode"> |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | $html = ob_get_clean(); |
| 417 | 417 | |
| 418 | 418 | // remove line breaks so we can use it in js |
| 419 | - return preg_replace( "/\r|\n/", "", trim( $html ) ); |
|
| 419 | + return preg_replace("/\r|\n/", "", trim($html)); |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | /** |
@@ -474,7 +474,7 @@ discard block |
||
| 474 | 474 | jQuery($this).data('sd-widget-enabled', true); |
| 475 | 475 | } |
| 476 | 476 | |
| 477 | - var $button = '<button title="<?php _e( 'Advanced Settings' );?>" class="button button-primary right sd-advanced-button" onclick="sd_so_toggle_advanced(this);return false;"><i class="fas fa-sliders-h" aria-hidden="true"></i></button>'; |
|
| 477 | + var $button = '<button title="<?php _e('Advanced Settings'); ?>" class="button button-primary right sd-advanced-button" onclick="sd_so_toggle_advanced(this);return false;"><i class="fas fa-sliders-h" aria-hidden="true"></i></button>'; |
|
| 478 | 478 | var form = jQuery($this).parents('' + $selector + ''); |
| 479 | 479 | |
| 480 | 480 | if (jQuery($this).val() == '1' && jQuery(form).find('.sd-advanced-button').length == 0) { |
@@ -511,10 +511,10 @@ discard block |
||
| 511 | 511 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 512 | 512 | */ |
| 513 | 513 | |
| 514 | - return str_replace( array( |
|
| 514 | + return str_replace(array( |
|
| 515 | 515 | '<script>', |
| 516 | 516 | '</script>' |
| 517 | - ), '', $output ); |
|
| 517 | + ), '', $output); |
|
| 518 | 518 | } |
| 519 | 519 | |
| 520 | 520 | /** |
@@ -525,7 +525,7 @@ discard block |
||
| 525 | 525 | * @param string $editor_id |
| 526 | 526 | * @param string $insert_shortcode_function |
| 527 | 527 | */ |
| 528 | - public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) { |
|
| 528 | + public static function shortcode_insert_button_script($editor_id = '', $insert_shortcode_function = '') { |
|
| 529 | 529 | ?> |
| 530 | 530 | <style> |
| 531 | 531 | .sd-shortcode-left-wrap { |
@@ -644,7 +644,7 @@ discard block |
||
| 644 | 644 | width: 100%; |
| 645 | 645 | } |
| 646 | 646 | |
| 647 | - <?php if ( function_exists( 'generate_sections_sections_metabox' ) ) { ?> |
|
| 647 | + <?php if (function_exists('generate_sections_sections_metabox')) { ?> |
|
| 648 | 648 | .generate-sections-modal #custom-media-buttons > .sd-lable-shortcode-inserter { |
| 649 | 649 | display: inline; |
| 650 | 650 | } |
@@ -652,15 +652,15 @@ discard block |
||
| 652 | 652 | <?php } ?> |
| 653 | 653 | </style> |
| 654 | 654 | <?php |
| 655 | - if ( class_exists( 'SiteOrigin_Panels' ) ) { |
|
| 655 | + if (class_exists('SiteOrigin_Panels')) { |
|
| 656 | 656 | echo "<script>" . self::siteorigin_js() . "</script>"; |
| 657 | 657 | } |
| 658 | 658 | ?> |
| 659 | 659 | <script> |
| 660 | 660 | <?php |
| 661 | - if(! empty( $insert_shortcode_function )){ |
|
| 661 | + if (!empty($insert_shortcode_function)) { |
|
| 662 | 662 | echo $insert_shortcode_function; |
| 663 | - }else{ |
|
| 663 | + } else { |
|
| 664 | 664 | |
| 665 | 665 | /** |
| 666 | 666 | * Function for super duper insert shortcode. |
@@ -673,9 +673,9 @@ discard block |
||
| 673 | 673 | if ($shortcode) { |
| 674 | 674 | if (!$editor_id) { |
| 675 | 675 | <?php |
| 676 | - if ( isset( $_REQUEST['et_fb'] ) ) { |
|
| 676 | + if (isset($_REQUEST['et_fb'])) { |
|
| 677 | 677 | echo '$editor_id = "#main_content_content_vb_tiny_mce";'; |
| 678 | - } elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) { |
|
| 678 | + } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor') { |
|
| 679 | 679 | echo '$editor_id = "#elementor-controls .wp-editor-container textarea";'; |
| 680 | 680 | } else { |
| 681 | 681 | echo '$editor_id = "#wp-content-editor-container textarea";'; |
@@ -760,11 +760,11 @@ discard block |
||
| 760 | 760 | 'shortcode': $short_code, |
| 761 | 761 | 'attributes': 123, |
| 762 | 762 | 'post_id': 321, |
| 763 | - '_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>' |
|
| 763 | + '_ajax_nonce': '<?php echo wp_create_nonce('super_duper_output_shortcode'); ?>' |
|
| 764 | 764 | }; |
| 765 | 765 | |
| 766 | 766 | if (typeof ajaxurl === 'undefined') { |
| 767 | - var ajaxurl = "<?php echo admin_url( 'admin-ajax.php' );?>"; |
|
| 767 | + var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>"; |
|
| 768 | 768 | } |
| 769 | 769 | |
| 770 | 770 | jQuery.post(ajaxurl, data, function (response) { |
@@ -973,11 +973,11 @@ discard block |
||
| 973 | 973 | var data = { |
| 974 | 974 | 'action': 'super_duper_get_picker', |
| 975 | 975 | 'editor_id': $id, |
| 976 | - '_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_picker' );?>' |
|
| 976 | + '_ajax_nonce': '<?php echo wp_create_nonce('super_duper_picker'); ?>' |
|
| 977 | 977 | }; |
| 978 | 978 | |
| 979 | 979 | if (!ajaxurl) { |
| 980 | - var ajaxurl = "<?php echo admin_url( 'admin-ajax.php' ); ?>"; |
|
| 980 | + var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>"; |
|
| 981 | 981 | } |
| 982 | 982 | |
| 983 | 983 | jQuery.post(ajaxurl, data, function (response) { |
@@ -998,9 +998,9 @@ discard block |
||
| 998 | 998 | */ |
| 999 | 999 | function sd_shortcode_button($id) { |
| 1000 | 1000 | if ($id) { |
| 1001 | - return '<?php echo self::shortcode_button( "\\''+\$id+'\\'" );?>'; |
|
| 1001 | + return '<?php echo self::shortcode_button("\\''+\$id+'\\'"); ?>'; |
|
| 1002 | 1002 | } else { |
| 1003 | - return '<?php echo self::shortcode_button();?>'; |
|
| 1003 | + return '<?php echo self::shortcode_button(); ?>'; |
|
| 1004 | 1004 | } |
| 1005 | 1005 | } |
| 1006 | 1006 | |
@@ -1015,11 +1015,11 @@ discard block |
||
| 1015 | 1015 | * |
| 1016 | 1016 | * @return mixed |
| 1017 | 1017 | */ |
| 1018 | - public function widget_css( $advanced = true ) { |
|
| 1018 | + public function widget_css($advanced = true) { |
|
| 1019 | 1019 | ob_start(); |
| 1020 | 1020 | ?> |
| 1021 | 1021 | <style> |
| 1022 | - <?php if( $advanced ){ ?> |
|
| 1022 | + <?php if ($advanced) { ?> |
|
| 1023 | 1023 | .sd-advanced-setting { |
| 1024 | 1024 | display: none; |
| 1025 | 1025 | } |
@@ -1061,10 +1061,10 @@ discard block |
||
| 1061 | 1061 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1062 | 1062 | */ |
| 1063 | 1063 | |
| 1064 | - return str_replace( array( |
|
| 1064 | + return str_replace(array( |
|
| 1065 | 1065 | '<style>', |
| 1066 | 1066 | '</style>' |
| 1067 | - ), '', $output ); |
|
| 1067 | + ), '', $output); |
|
| 1068 | 1068 | } |
| 1069 | 1069 | |
| 1070 | 1070 | /** |
@@ -1134,7 +1134,7 @@ discard block |
||
| 1134 | 1134 | jQuery($this).data('sd-widget-enabled', true); |
| 1135 | 1135 | } |
| 1136 | 1136 | |
| 1137 | - var $button = '<button title="<?php _e( 'Advanced Settings' );?>" style="line-height: 28px;" class="button button-primary right sd-advanced-button" onclick="sd_toggle_advanced(this);return false;"><span class="dashicons dashicons-admin-settings" style="width: 28px;font-size: 28px;"></span></button>'; |
|
| 1137 | + var $button = '<button title="<?php _e('Advanced Settings'); ?>" style="line-height: 28px;" class="button button-primary right sd-advanced-button" onclick="sd_toggle_advanced(this);return false;"><span class="dashicons dashicons-admin-settings" style="width: 28px;font-size: 28px;"></span></button>'; |
|
| 1138 | 1138 | var form = jQuery($this).parents('' + $selector + ''); |
| 1139 | 1139 | |
| 1140 | 1140 | if (jQuery($this).val() == '1' && jQuery(form).find('.sd-advanced-button').length == 0) { |
@@ -1226,7 +1226,7 @@ discard block |
||
| 1226 | 1226 | }); |
| 1227 | 1227 | |
| 1228 | 1228 | } |
| 1229 | - <?php do_action( 'wp_super_duper_widget_js', $this ); ?> |
|
| 1229 | + <?php do_action('wp_super_duper_widget_js', $this); ?> |
|
| 1230 | 1230 | </script> |
| 1231 | 1231 | <?php |
| 1232 | 1232 | $output = ob_get_clean(); |
@@ -1235,10 +1235,10 @@ discard block |
||
| 1235 | 1235 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1236 | 1236 | */ |
| 1237 | 1237 | |
| 1238 | - return str_replace( array( |
|
| 1238 | + return str_replace(array( |
|
| 1239 | 1239 | '<script>', |
| 1240 | 1240 | '</script>' |
| 1241 | - ), '', $output ); |
|
| 1241 | + ), '', $output); |
|
| 1242 | 1242 | } |
| 1243 | 1243 | |
| 1244 | 1244 | |
@@ -1249,14 +1249,14 @@ discard block |
||
| 1249 | 1249 | * |
| 1250 | 1250 | * @return mixed |
| 1251 | 1251 | */ |
| 1252 | - private function add_name_from_key( $options, $arguments = false ) { |
|
| 1253 | - if ( ! empty( $options['arguments'] ) ) { |
|
| 1254 | - foreach ( $options['arguments'] as $key => $val ) { |
|
| 1255 | - $options['arguments'][ $key ]['name'] = $key; |
|
| 1252 | + private function add_name_from_key($options, $arguments = false) { |
|
| 1253 | + if (!empty($options['arguments'])) { |
|
| 1254 | + foreach ($options['arguments'] as $key => $val) { |
|
| 1255 | + $options['arguments'][$key]['name'] = $key; |
|
| 1256 | 1256 | } |
| 1257 | - } elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) { |
|
| 1258 | - foreach ( $options as $key => $val ) { |
|
| 1259 | - $options[ $key ]['name'] = $key; |
|
| 1257 | + } elseif ($arguments && is_array($options) && !empty($options)) { |
|
| 1258 | + foreach ($options as $key => $val) { |
|
| 1259 | + $options[$key]['name'] = $key; |
|
| 1260 | 1260 | } |
| 1261 | 1261 | } |
| 1262 | 1262 | |
@@ -1269,8 +1269,8 @@ discard block |
||
| 1269 | 1269 | * @since 1.0.0 |
| 1270 | 1270 | */ |
| 1271 | 1271 | public function register_shortcode() { |
| 1272 | - add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) ); |
|
| 1273 | - add_action( 'wp_ajax_super_duper_output_shortcode', array( __CLASS__, 'render_shortcode' ) ); |
|
| 1272 | + add_shortcode($this->base_id, array($this, 'shortcode_output')); |
|
| 1273 | + add_action('wp_ajax_super_duper_output_shortcode', array(__CLASS__, 'render_shortcode')); |
|
| 1274 | 1274 | } |
| 1275 | 1275 | |
| 1276 | 1276 | /** |
@@ -1280,33 +1280,33 @@ discard block |
||
| 1280 | 1280 | */ |
| 1281 | 1281 | public static function render_shortcode() { |
| 1282 | 1282 | |
| 1283 | - check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true ); |
|
| 1284 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 1283 | + check_ajax_referer('super_duper_output_shortcode', '_ajax_nonce', true); |
|
| 1284 | + if (!current_user_can('manage_options')) { |
|
| 1285 | 1285 | wp_die(); |
| 1286 | 1286 | } |
| 1287 | 1287 | |
| 1288 | 1288 | // we might need the $post value here so lets set it. |
| 1289 | - if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) { |
|
| 1290 | - $post_obj = get_post( absint( $_POST['post_id'] ) ); |
|
| 1291 | - if ( ! empty( $post_obj ) && empty( $post ) ) { |
|
| 1289 | + if (isset($_POST['post_id']) && $_POST['post_id']) { |
|
| 1290 | + $post_obj = get_post(absint($_POST['post_id'])); |
|
| 1291 | + if (!empty($post_obj) && empty($post)) { |
|
| 1292 | 1292 | global $post; |
| 1293 | 1293 | $post = $post_obj; |
| 1294 | 1294 | } |
| 1295 | 1295 | } |
| 1296 | 1296 | |
| 1297 | - if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) { |
|
| 1298 | - $shortcode_name = sanitize_title_with_dashes( $_POST['shortcode'] ); |
|
| 1299 | - $attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array(); |
|
| 1297 | + if (isset($_POST['shortcode']) && $_POST['shortcode']) { |
|
| 1298 | + $shortcode_name = sanitize_title_with_dashes($_POST['shortcode']); |
|
| 1299 | + $attributes_array = isset($_POST['attributes']) && $_POST['attributes'] ? $_POST['attributes'] : array(); |
|
| 1300 | 1300 | $attributes = ''; |
| 1301 | - if ( ! empty( $attributes_array ) ) { |
|
| 1302 | - foreach ( $attributes_array as $key => $value ) { |
|
| 1303 | - $attributes .= " " . sanitize_title_with_dashes( $key ) . "='" . wp_slash( $value ) . "' "; |
|
| 1301 | + if (!empty($attributes_array)) { |
|
| 1302 | + foreach ($attributes_array as $key => $value) { |
|
| 1303 | + $attributes .= " " . sanitize_title_with_dashes($key) . "='" . wp_slash($value) . "' "; |
|
| 1304 | 1304 | } |
| 1305 | 1305 | } |
| 1306 | 1306 | |
| 1307 | 1307 | $shortcode = "[" . $shortcode_name . " " . $attributes . "]"; |
| 1308 | 1308 | |
| 1309 | - echo do_shortcode( $shortcode ); |
|
| 1309 | + echo do_shortcode($shortcode); |
|
| 1310 | 1310 | |
| 1311 | 1311 | } |
| 1312 | 1312 | wp_die(); |
@@ -1320,44 +1320,44 @@ discard block |
||
| 1320 | 1320 | * |
| 1321 | 1321 | * @return string |
| 1322 | 1322 | */ |
| 1323 | - public function shortcode_output( $args = array(), $content = '' ) { |
|
| 1324 | - $args = self::argument_values( $args ); |
|
| 1323 | + public function shortcode_output($args = array(), $content = '') { |
|
| 1324 | + $args = self::argument_values($args); |
|
| 1325 | 1325 | |
| 1326 | 1326 | // add extra argument so we know its a output to gutenberg |
| 1327 | 1327 | //$args |
| 1328 | - $args = $this->string_to_bool( $args ); |
|
| 1328 | + $args = $this->string_to_bool($args); |
|
| 1329 | 1329 | |
| 1330 | 1330 | // if we have a enclosed shortcode we add it to the special `html` argument |
| 1331 | - if ( ! empty( $content ) ) { |
|
| 1331 | + if (!empty($content)) { |
|
| 1332 | 1332 | $args['html'] = $content; |
| 1333 | 1333 | } |
| 1334 | 1334 | |
| 1335 | - $class = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : ''; |
|
| 1335 | + $class = isset($this->options['widget_ops']['classname']) ? esc_attr($this->options['widget_ops']['classname']) : ''; |
|
| 1336 | 1336 | |
| 1337 | - $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this ); |
|
| 1338 | - $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this ); |
|
| 1337 | + $class = apply_filters('wp_super_duper_div_classname', $class, $args, $this); |
|
| 1338 | + $class = apply_filters('wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this); |
|
| 1339 | 1339 | |
| 1340 | - $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this ); |
|
| 1341 | - $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this ); //@todo this does not seem right @kiran? |
|
| 1340 | + $attrs = apply_filters('wp_super_duper_div_attrs', '', $args, $this); |
|
| 1341 | + $attrs = apply_filters('wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this); //@todo this does not seem right @kiran? |
|
| 1342 | 1342 | |
| 1343 | 1343 | $shortcode_args = array(); |
| 1344 | 1344 | $output = ''; |
| 1345 | - $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false; |
|
| 1346 | - if ( isset( $args['no_wrap'] ) && $args['no_wrap'] ) { |
|
| 1345 | + $no_wrap = isset($this->options['no_wrap']) && $this->options['no_wrap'] ? true : false; |
|
| 1346 | + if (isset($args['no_wrap']) && $args['no_wrap']) { |
|
| 1347 | 1347 | $no_wrap = true; |
| 1348 | 1348 | } |
| 1349 | - $main_content = $this->output( $args, $shortcode_args, $content ); |
|
| 1350 | - if ( $main_content && ! $no_wrap ) { |
|
| 1349 | + $main_content = $this->output($args, $shortcode_args, $content); |
|
| 1350 | + if ($main_content && !$no_wrap) { |
|
| 1351 | 1351 | // wrap the shortcode in a div with the same class as the widget |
| 1352 | 1352 | $output .= '<div class="' . $class . '" ' . $attrs . '>'; |
| 1353 | - if ( ! empty( $args['title'] ) ) { |
|
| 1353 | + if (!empty($args['title'])) { |
|
| 1354 | 1354 | // if its a shortcode and there is a title try to grab the title wrappers |
| 1355 | - $shortcode_args = array( 'before_title' => '', 'after_title' => '' ); |
|
| 1356 | - if ( empty( $instance ) ) { |
|
| 1355 | + $shortcode_args = array('before_title' => '', 'after_title' => ''); |
|
| 1356 | + if (empty($instance)) { |
|
| 1357 | 1357 | global $wp_registered_sidebars; |
| 1358 | - if ( ! empty( $wp_registered_sidebars ) ) { |
|
| 1359 | - foreach ( $wp_registered_sidebars as $sidebar ) { |
|
| 1360 | - if ( ! empty( $sidebar['before_title'] ) ) { |
|
| 1358 | + if (!empty($wp_registered_sidebars)) { |
|
| 1359 | + foreach ($wp_registered_sidebars as $sidebar) { |
|
| 1360 | + if (!empty($sidebar['before_title'])) { |
|
| 1361 | 1361 | $shortcode_args['before_title'] = $sidebar['before_title']; |
| 1362 | 1362 | $shortcode_args['after_title'] = $sidebar['after_title']; |
| 1363 | 1363 | break; |
@@ -1365,20 +1365,20 @@ discard block |
||
| 1365 | 1365 | } |
| 1366 | 1366 | } |
| 1367 | 1367 | } |
| 1368 | - $output .= $this->output_title( $shortcode_args, $args ); |
|
| 1368 | + $output .= $this->output_title($shortcode_args, $args); |
|
| 1369 | 1369 | } |
| 1370 | 1370 | $output .= $main_content; |
| 1371 | 1371 | $output .= '</div>'; |
| 1372 | - } elseif ( $main_content && $no_wrap ) { |
|
| 1372 | + } elseif ($main_content && $no_wrap) { |
|
| 1373 | 1373 | $output .= $main_content; |
| 1374 | 1374 | } |
| 1375 | 1375 | |
| 1376 | 1376 | // if preview show a placeholder if empty |
| 1377 | - if ( $this->is_preview() && $output == '' ) { |
|
| 1378 | - $output = $this->preview_placeholder_text( "[{" . $this->base_id . "}]" ); |
|
| 1377 | + if ($this->is_preview() && $output == '') { |
|
| 1378 | + $output = $this->preview_placeholder_text("[{" . $this->base_id . "}]"); |
|
| 1379 | 1379 | } |
| 1380 | 1380 | |
| 1381 | - return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this ); |
|
| 1381 | + return apply_filters('wp_super_duper_widget_output', $output, $args, $shortcode_args, $this); |
|
| 1382 | 1382 | } |
| 1383 | 1383 | |
| 1384 | 1384 | /** |
@@ -1388,8 +1388,8 @@ discard block |
||
| 1388 | 1388 | * |
| 1389 | 1389 | * @return string |
| 1390 | 1390 | */ |
| 1391 | - public function preview_placeholder_text( $name = '' ) { |
|
| 1392 | - return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf( __( 'Placeholder for: %s' ), $name ) . "</div>"; |
|
| 1391 | + public function preview_placeholder_text($name = '') { |
|
| 1392 | + return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf(__('Placeholder for: %s'), $name) . "</div>"; |
|
| 1393 | 1393 | } |
| 1394 | 1394 | |
| 1395 | 1395 | /** |
@@ -1399,13 +1399,13 @@ discard block |
||
| 1399 | 1399 | * |
| 1400 | 1400 | * @return mixed |
| 1401 | 1401 | */ |
| 1402 | - public function string_to_bool( $options ) { |
|
| 1402 | + public function string_to_bool($options) { |
|
| 1403 | 1403 | // convert bool strings to booleans |
| 1404 | - foreach ( $options as $key => $val ) { |
|
| 1405 | - if ( $val == 'false' ) { |
|
| 1406 | - $options[ $key ] = false; |
|
| 1407 | - } elseif ( $val == 'true' ) { |
|
| 1408 | - $options[ $key ] = true; |
|
| 1404 | + foreach ($options as $key => $val) { |
|
| 1405 | + if ($val == 'false') { |
|
| 1406 | + $options[$key] = false; |
|
| 1407 | + } elseif ($val == 'true') { |
|
| 1408 | + $options[$key] = true; |
|
| 1409 | 1409 | } |
| 1410 | 1410 | } |
| 1411 | 1411 | |
@@ -1421,26 +1421,26 @@ discard block |
||
| 1421 | 1421 | * |
| 1422 | 1422 | * @return array |
| 1423 | 1423 | */ |
| 1424 | - public function argument_values( $instance ) { |
|
| 1424 | + public function argument_values($instance) { |
|
| 1425 | 1425 | $argument_values = array(); |
| 1426 | 1426 | |
| 1427 | 1427 | // set widget instance |
| 1428 | 1428 | $this->instance = $instance; |
| 1429 | 1429 | |
| 1430 | - if ( empty( $this->arguments ) ) { |
|
| 1430 | + if (empty($this->arguments)) { |
|
| 1431 | 1431 | $this->arguments = $this->get_arguments(); |
| 1432 | 1432 | } |
| 1433 | 1433 | |
| 1434 | - if ( ! empty( $this->arguments ) ) { |
|
| 1435 | - foreach ( $this->arguments as $key => $args ) { |
|
| 1434 | + if (!empty($this->arguments)) { |
|
| 1435 | + foreach ($this->arguments as $key => $args) { |
|
| 1436 | 1436 | // set the input name from the key |
| 1437 | 1437 | $args['name'] = $key; |
| 1438 | 1438 | // |
| 1439 | - $argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : ''; |
|
| 1440 | - if ( $args['type'] == 'checkbox' && $argument_values[ $key ] == '' ) { |
|
| 1439 | + $argument_values[$key] = isset($instance[$key]) ? $instance[$key] : ''; |
|
| 1440 | + if ($args['type'] == 'checkbox' && $argument_values[$key] == '') { |
|
| 1441 | 1441 | // don't set default for an empty checkbox |
| 1442 | - } elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) { |
|
| 1443 | - $argument_values[ $key ] = $args['default']; |
|
| 1442 | + } elseif ($argument_values[$key] == '' && isset($args['default'])) { |
|
| 1443 | + $argument_values[$key] = $args['default']; |
|
| 1444 | 1444 | } |
| 1445 | 1445 | } |
| 1446 | 1446 | } |
@@ -1467,12 +1467,12 @@ discard block |
||
| 1467 | 1467 | * @return array Get arguments. |
| 1468 | 1468 | */ |
| 1469 | 1469 | public function get_arguments() { |
| 1470 | - if ( empty( $this->arguments ) ) { |
|
| 1470 | + if (empty($this->arguments)) { |
|
| 1471 | 1471 | $this->arguments = $this->set_arguments(); |
| 1472 | 1472 | } |
| 1473 | 1473 | |
| 1474 | - $this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance ); |
|
| 1475 | - $this->arguments = $this->add_name_from_key( $this->arguments, true ); |
|
| 1474 | + $this->arguments = apply_filters('wp_super_duper_arguments', $this->arguments, $this->options, $this->instance); |
|
| 1475 | + $this->arguments = $this->add_name_from_key($this->arguments, true); |
|
| 1476 | 1476 | |
| 1477 | 1477 | return $this->arguments; |
| 1478 | 1478 | } |
@@ -1484,7 +1484,7 @@ discard block |
||
| 1484 | 1484 | * @param array $widget_args |
| 1485 | 1485 | * @param string $content |
| 1486 | 1486 | */ |
| 1487 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 1487 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
| 1488 | 1488 | |
| 1489 | 1489 | } |
| 1490 | 1490 | |
@@ -1492,10 +1492,10 @@ discard block |
||
| 1492 | 1492 | * Add the dynamic block code inline when the wp-block in enqueued. |
| 1493 | 1493 | */ |
| 1494 | 1494 | public function register_block() { |
| 1495 | - wp_add_inline_script( 'wp-blocks', $this->block() ); |
|
| 1496 | - if ( class_exists( 'SiteOrigin_Panels' ) ) { |
|
| 1495 | + wp_add_inline_script('wp-blocks', $this->block()); |
|
| 1496 | + if (class_exists('SiteOrigin_Panels')) { |
|
| 1497 | 1497 | |
| 1498 | - wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() ); |
|
| 1498 | + wp_add_inline_script('wp-blocks', $this->siteorigin_js()); |
|
| 1499 | 1499 | |
| 1500 | 1500 | } |
| 1501 | 1501 | } |
@@ -1510,13 +1510,13 @@ discard block |
||
| 1510 | 1510 | $show = false; |
| 1511 | 1511 | $arguments = $this->arguments; |
| 1512 | 1512 | |
| 1513 | - if ( empty( $arguments ) ) { |
|
| 1513 | + if (empty($arguments)) { |
|
| 1514 | 1514 | $arguments = $this->get_arguments(); |
| 1515 | 1515 | } |
| 1516 | 1516 | |
| 1517 | - if ( ! empty( $arguments ) ) { |
|
| 1518 | - foreach ( $arguments as $argument ) { |
|
| 1519 | - if ( isset( $argument['advanced'] ) && $argument['advanced'] ) { |
|
| 1517 | + if (!empty($arguments)) { |
|
| 1518 | + foreach ($arguments as $argument) { |
|
| 1519 | + if (isset($argument['advanced']) && $argument['advanced']) { |
|
| 1520 | 1520 | $show = true; |
| 1521 | 1521 | break; // no need to continue if we know we have it |
| 1522 | 1522 | } |
@@ -1535,15 +1535,15 @@ discard block |
||
| 1535 | 1535 | |
| 1536 | 1536 | $url = $this->url; |
| 1537 | 1537 | |
| 1538 | - if ( ! $url ) { |
|
| 1538 | + if (!$url) { |
|
| 1539 | 1539 | // check if we are inside a plugin |
| 1540 | - $file_dir = str_replace( "/includes", "", dirname( __FILE__ ) ); |
|
| 1540 | + $file_dir = str_replace("/includes", "", dirname(__FILE__)); |
|
| 1541 | 1541 | |
| 1542 | - $dir_parts = explode( "/wp-content/", $file_dir ); |
|
| 1543 | - $url_parts = explode( "/wp-content/", plugins_url() ); |
|
| 1542 | + $dir_parts = explode("/wp-content/", $file_dir); |
|
| 1543 | + $url_parts = explode("/wp-content/", plugins_url()); |
|
| 1544 | 1544 | |
| 1545 | - if ( ! empty( $url_parts[0] ) && ! empty( $dir_parts[1] ) ) { |
|
| 1546 | - $url = trailingslashit( $url_parts[0] . "/wp-content/" . $dir_parts[1] ); |
|
| 1545 | + if (!empty($url_parts[0]) && !empty($dir_parts[1])) { |
|
| 1546 | + $url = trailingslashit($url_parts[0] . "/wp-content/" . $dir_parts[1]); |
|
| 1547 | 1547 | $this->url = $url; |
| 1548 | 1548 | } |
| 1549 | 1549 | } |
@@ -1564,46 +1564,46 @@ discard block |
||
| 1564 | 1564 | * @since 1.1.0 |
| 1565 | 1565 | * @return string |
| 1566 | 1566 | */ |
| 1567 | - public function get_block_icon( $icon ) { |
|
| 1567 | + public function get_block_icon($icon) { |
|
| 1568 | 1568 | |
| 1569 | 1569 | // check if we have a Font Awesome icon |
| 1570 | 1570 | $fa_type = ''; |
| 1571 | - if ( substr( $icon, 0, 7 ) === "fas fa-" ) { |
|
| 1571 | + if (substr($icon, 0, 7) === "fas fa-") { |
|
| 1572 | 1572 | $fa_type = 'solid'; |
| 1573 | - } elseif ( substr( $icon, 0, 7 ) === "far fa-" ) { |
|
| 1573 | + } elseif (substr($icon, 0, 7) === "far fa-") { |
|
| 1574 | 1574 | $fa_type = 'regular'; |
| 1575 | - } elseif ( substr( $icon, 0, 7 ) === "fab fa-" ) { |
|
| 1575 | + } elseif (substr($icon, 0, 7) === "fab fa-") { |
|
| 1576 | 1576 | $fa_type = 'brands'; |
| 1577 | 1577 | } else { |
| 1578 | 1578 | $icon = "'" . $icon . "'"; |
| 1579 | 1579 | } |
| 1580 | 1580 | |
| 1581 | 1581 | // set the icon if we found one |
| 1582 | - if ( $fa_type ) { |
|
| 1583 | - $fa_icon = str_replace( array( "fas fa-", "far fa-", "fab fa-" ), "", $icon ); |
|
| 1582 | + if ($fa_type) { |
|
| 1583 | + $fa_icon = str_replace(array("fas fa-", "far fa-", "fab fa-"), "", $icon); |
|
| 1584 | 1584 | $icon = "el('svg',{width: 20, height: 20, viewBox: '0 0 20 20'},el('use', {'xlink:href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "','href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "'}))"; |
| 1585 | 1585 | } |
| 1586 | 1586 | |
| 1587 | 1587 | return $icon; |
| 1588 | 1588 | } |
| 1589 | 1589 | |
| 1590 | - public function group_arguments( $arguments ) { |
|
| 1590 | + public function group_arguments($arguments) { |
|
| 1591 | 1591 | // echo '###';print_r($arguments); |
| 1592 | - if ( ! empty( $arguments ) ) { |
|
| 1592 | + if (!empty($arguments)) { |
|
| 1593 | 1593 | $temp_arguments = array(); |
| 1594 | - $general = __( "General" ); |
|
| 1594 | + $general = __("General"); |
|
| 1595 | 1595 | $add_sections = false; |
| 1596 | - foreach ( $arguments as $key => $args ) { |
|
| 1597 | - if ( isset( $args['group'] ) ) { |
|
| 1598 | - $temp_arguments[ $args['group'] ][ $key ] = $args; |
|
| 1596 | + foreach ($arguments as $key => $args) { |
|
| 1597 | + if (isset($args['group'])) { |
|
| 1598 | + $temp_arguments[$args['group']][$key] = $args; |
|
| 1599 | 1599 | $add_sections = true; |
| 1600 | 1600 | } else { |
| 1601 | - $temp_arguments[ $general ][ $key ] = $args; |
|
| 1601 | + $temp_arguments[$general][$key] = $args; |
|
| 1602 | 1602 | } |
| 1603 | 1603 | } |
| 1604 | 1604 | |
| 1605 | 1605 | // only add sections if more than one |
| 1606 | - if ( $add_sections ) { |
|
| 1606 | + if ($add_sections) { |
|
| 1607 | 1607 | $arguments = $temp_arguments; |
| 1608 | 1608 | } |
| 1609 | 1609 | } |
@@ -1656,30 +1656,30 @@ discard block |
||
| 1656 | 1656 | * @return {?WPBlock} The block, if it has been successfully |
| 1657 | 1657 | * registered; otherwise `undefined`. |
| 1658 | 1658 | */ |
| 1659 | - registerBlockType('<?php echo str_replace( "_", "-", sanitize_title_with_dashes( $this->options['textdomain'] ) . '/' . sanitize_title_with_dashes( $this->options['class_name'] ) ); ?>', { // Block name. Block names must be string that contains a namespace prefix. Example: my-plugin/my-custom-block. |
|
| 1660 | - title: '<?php echo addslashes( $this->options['name'] ); ?>', // Block title. |
|
| 1661 | - description: '<?php echo addslashes( $this->options['widget_ops']['description'] )?>', // Block title. |
|
| 1662 | - icon: <?php echo $this->get_block_icon( $this->options['block-icon'] );?>,//'<?php echo isset( $this->options['block-icon'] ) ? esc_attr( $this->options['block-icon'] ) : 'shield-alt';?>', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/. |
|
| 1659 | + registerBlockType('<?php echo str_replace("_", "-", sanitize_title_with_dashes($this->options['textdomain']) . '/' . sanitize_title_with_dashes($this->options['class_name'])); ?>', { // Block name. Block names must be string that contains a namespace prefix. Example: my-plugin/my-custom-block. |
|
| 1660 | + title: '<?php echo addslashes($this->options['name']); ?>', // Block title. |
|
| 1661 | + description: '<?php echo addslashes($this->options['widget_ops']['description'])?>', // Block title. |
|
| 1662 | + icon: <?php echo $this->get_block_icon($this->options['block-icon']); ?>,//'<?php echo isset($this->options['block-icon']) ? esc_attr($this->options['block-icon']) : 'shield-alt'; ?>', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/. |
|
| 1663 | 1663 | supports: { |
| 1664 | 1664 | <?php |
| 1665 | - if ( isset( $this->options['block-supports'] ) ) { |
|
| 1666 | - echo $this->array_to_attributes( $this->options['block-supports'] ); |
|
| 1665 | + if (isset($this->options['block-supports'])) { |
|
| 1666 | + echo $this->array_to_attributes($this->options['block-supports']); |
|
| 1667 | 1667 | } |
| 1668 | 1668 | ?> |
| 1669 | 1669 | }, |
| 1670 | - category: '<?php echo isset( $this->options['block-category'] ) ? esc_attr( $this->options['block-category'] ) : 'common';?>', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed. |
|
| 1671 | - <?php if ( isset( $this->options['block-keywords'] ) ) { |
|
| 1670 | + category: '<?php echo isset($this->options['block-category']) ? esc_attr($this->options['block-category']) : 'common'; ?>', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed. |
|
| 1671 | + <?php if (isset($this->options['block-keywords'])) { |
|
| 1672 | 1672 | echo "keywords : " . $this->options['block-keywords'] . ","; |
| 1673 | 1673 | }?> |
| 1674 | 1674 | |
| 1675 | 1675 | <?php |
| 1676 | 1676 | |
| 1677 | 1677 | // maybe set no_wrap |
| 1678 | - $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false; |
|
| 1679 | - if ( isset( $this->arguments['no_wrap'] ) && $this->arguments['no_wrap'] ) { |
|
| 1678 | + $no_wrap = isset($this->options['no_wrap']) && $this->options['no_wrap'] ? true : false; |
|
| 1679 | + if (isset($this->arguments['no_wrap']) && $this->arguments['no_wrap']) { |
|
| 1680 | 1680 | $no_wrap = true; |
| 1681 | 1681 | } |
| 1682 | - if ( $no_wrap ) { |
|
| 1682 | + if ($no_wrap) { |
|
| 1683 | 1683 | $this->options['block-wrap'] = ''; |
| 1684 | 1684 | } |
| 1685 | 1685 | |
@@ -1692,10 +1692,10 @@ discard block |
||
| 1692 | 1692 | echo " html: false"; |
| 1693 | 1693 | echo "},";*/ |
| 1694 | 1694 | |
| 1695 | - if ( ! empty( $this->arguments ) ) { |
|
| 1695 | + if (!empty($this->arguments)) { |
|
| 1696 | 1696 | echo "attributes : {"; |
| 1697 | 1697 | |
| 1698 | - if ( $show_advanced ) { |
|
| 1698 | + if ($show_advanced) { |
|
| 1699 | 1699 | echo "show_advanced: {"; |
| 1700 | 1700 | echo " type: 'boolean',"; |
| 1701 | 1701 | echo " default: false,"; |
@@ -1703,41 +1703,41 @@ discard block |
||
| 1703 | 1703 | } |
| 1704 | 1704 | |
| 1705 | 1705 | // block wrap element |
| 1706 | - if ( ! empty( $this->options['block-wrap'] ) ) { //@todo we should validate this? |
|
| 1706 | + if (!empty($this->options['block-wrap'])) { //@todo we should validate this? |
|
| 1707 | 1707 | echo "block_wrap: {"; |
| 1708 | 1708 | echo " type: 'string',"; |
| 1709 | - echo " default: '" . esc_attr( $this->options['block-wrap'] ) . "',"; |
|
| 1709 | + echo " default: '" . esc_attr($this->options['block-wrap']) . "',"; |
|
| 1710 | 1710 | echo "},"; |
| 1711 | 1711 | } |
| 1712 | 1712 | |
| 1713 | - foreach ( $this->arguments as $key => $args ) { |
|
| 1713 | + foreach ($this->arguments as $key => $args) { |
|
| 1714 | 1714 | |
| 1715 | 1715 | // set if we should show alignment |
| 1716 | - if ( $key == 'alignment' ) { |
|
| 1716 | + if ($key == 'alignment') { |
|
| 1717 | 1717 | $show_alignment = true; |
| 1718 | 1718 | } |
| 1719 | 1719 | |
| 1720 | 1720 | $extra = ''; |
| 1721 | 1721 | |
| 1722 | - if ( $args['type'] == 'checkbox' ) { |
|
| 1722 | + if ($args['type'] == 'checkbox') { |
|
| 1723 | 1723 | $type = 'boolean'; |
| 1724 | - $default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false'; |
|
| 1725 | - } elseif ( $args['type'] == 'number' ) { |
|
| 1724 | + $default = isset($args['default']) && $args['default'] ? 'true' : 'false'; |
|
| 1725 | + } elseif ($args['type'] == 'number') { |
|
| 1726 | 1726 | $type = 'number'; |
| 1727 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 1728 | - } elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) { |
|
| 1727 | + $default = isset($args['default']) ? "'" . $args['default'] . "'" : "''"; |
|
| 1728 | + } elseif ($args['type'] == 'select' && !empty($args['multiple'])) { |
|
| 1729 | 1729 | $type = 'array'; |
| 1730 | - if ( is_array( $args['default'] ) ) { |
|
| 1731 | - $default = isset( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]"; |
|
| 1730 | + if (is_array($args['default'])) { |
|
| 1731 | + $default = isset($args['default']) ? "['" . implode("','", $args['default']) . "']" : "[]"; |
|
| 1732 | 1732 | } else { |
| 1733 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 1733 | + $default = isset($args['default']) ? "'" . $args['default'] . "'" : "''"; |
|
| 1734 | 1734 | } |
| 1735 | - } elseif ( $args['type'] == 'multiselect' ) { |
|
| 1735 | + } elseif ($args['type'] == 'multiselect') { |
|
| 1736 | 1736 | $type = 'array'; |
| 1737 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 1737 | + $default = isset($args['default']) ? "'" . $args['default'] . "'" : "''"; |
|
| 1738 | 1738 | } else { |
| 1739 | 1739 | $type = 'string'; |
| 1740 | - $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''"; |
|
| 1740 | + $default = isset($args['default']) ? "'" . $args['default'] . "'" : "''"; |
|
| 1741 | 1741 | } |
| 1742 | 1742 | echo $key . " : {"; |
| 1743 | 1743 | echo "type : '$type',"; |
@@ -1768,12 +1768,12 @@ discard block |
||
| 1768 | 1768 | is_fetching = true; |
| 1769 | 1769 | var data = { |
| 1770 | 1770 | 'action': 'super_duper_output_shortcode', |
| 1771 | - 'shortcode': '<?php echo $this->options['base_id'];?>', |
|
| 1771 | + 'shortcode': '<?php echo $this->options['base_id']; ?>', |
|
| 1772 | 1772 | 'attributes': props.attributes, |
| 1773 | - 'post_id': <?php global $post; if ( isset( $post->ID ) ) { |
|
| 1773 | + 'post_id': <?php global $post; if (isset($post->ID)) { |
|
| 1774 | 1774 | echo $post->ID; |
| 1775 | 1775 | }?>, |
| 1776 | - '_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>' |
|
| 1776 | + '_ajax_nonce': '<?php echo wp_create_nonce('super_duper_output_shortcode'); ?>' |
|
| 1777 | 1777 | }; |
| 1778 | 1778 | |
| 1779 | 1779 | jQuery.post(ajaxurl, data, function (response) { |
@@ -1782,7 +1782,7 @@ discard block |
||
| 1782 | 1782 | |
| 1783 | 1783 | // if the content is empty then we place some placeholder text |
| 1784 | 1784 | if (env == '') { |
| 1785 | - env = "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" + "<?php _e( 'Placeholder for: ' );?>" + props.name + "</div>"; |
|
| 1785 | + env = "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" + "<?php _e('Placeholder for: '); ?>" + props.name + "</div>"; |
|
| 1786 | 1786 | } |
| 1787 | 1787 | |
| 1788 | 1788 | props.setAttributes({content: env}); |
@@ -1801,7 +1801,7 @@ discard block |
||
| 1801 | 1801 | |
| 1802 | 1802 | el(wp.blockEditor.BlockControls, {key: 'controls'}, |
| 1803 | 1803 | |
| 1804 | - <?php if($show_alignment){?> |
|
| 1804 | + <?php if ($show_alignment) {?> |
|
| 1805 | 1805 | el( |
| 1806 | 1806 | wp.blockEditor.AlignmentToolbar, |
| 1807 | 1807 | { |
@@ -1819,9 +1819,9 @@ discard block |
||
| 1819 | 1819 | |
| 1820 | 1820 | <?php |
| 1821 | 1821 | |
| 1822 | - if(! empty( $this->arguments )){ |
|
| 1822 | + if (!empty($this->arguments)) { |
|
| 1823 | 1823 | |
| 1824 | - if ( $show_advanced ) { |
|
| 1824 | + if ($show_advanced) { |
|
| 1825 | 1825 | ?> |
| 1826 | 1826 | el('div', { |
| 1827 | 1827 | style: {'padding-left': '16px','padding-right': '16px'} |
@@ -1842,19 +1842,19 @@ discard block |
||
| 1842 | 1842 | |
| 1843 | 1843 | } |
| 1844 | 1844 | |
| 1845 | - $arguments = $this->group_arguments( $this->arguments ); |
|
| 1845 | + $arguments = $this->group_arguments($this->arguments); |
|
| 1846 | 1846 | |
| 1847 | 1847 | // Do we have sections? |
| 1848 | 1848 | $has_sections = $arguments == $this->arguments ? false : true; |
| 1849 | 1849 | |
| 1850 | 1850 | |
| 1851 | - if($has_sections){ |
|
| 1851 | + if ($has_sections) { |
|
| 1852 | 1852 | $panel_count = 0; |
| 1853 | - foreach($arguments as $key => $args){ |
|
| 1853 | + foreach ($arguments as $key => $args) { |
|
| 1854 | 1854 | ?> |
| 1855 | 1855 | el(wp.components.PanelBody, { |
| 1856 | - title: '<?php esc_attr_e( $key ); ?>', |
|
| 1857 | - initialOpen: <?php if ( $panel_count ) { |
|
| 1856 | + title: '<?php esc_attr_e($key); ?>', |
|
| 1857 | + initialOpen: <?php if ($panel_count) { |
|
| 1858 | 1858 | echo "false"; |
| 1859 | 1859 | } else { |
| 1860 | 1860 | echo "true"; |
@@ -1862,24 +1862,24 @@ discard block |
||
| 1862 | 1862 | }, |
| 1863 | 1863 | <?php |
| 1864 | 1864 | |
| 1865 | - foreach ( $args as $k => $a ) { |
|
| 1866 | - $this->build_block_arguments( $k, $a ); |
|
| 1865 | + foreach ($args as $k => $a) { |
|
| 1866 | + $this->build_block_arguments($k, $a); |
|
| 1867 | 1867 | } |
| 1868 | 1868 | ?> |
| 1869 | 1869 | ), |
| 1870 | 1870 | <?php |
| 1871 | - $panel_count ++; |
|
| 1871 | + $panel_count++; |
|
| 1872 | 1872 | |
| 1873 | 1873 | } |
| 1874 | - }else { |
|
| 1874 | + } else { |
|
| 1875 | 1875 | ?> |
| 1876 | 1876 | el(wp.components.PanelBody, { |
| 1877 | - title: '<?php esc_attr_e( "Settings" ); ?>', |
|
| 1877 | + title: '<?php esc_attr_e("Settings"); ?>', |
|
| 1878 | 1878 | initialOpen: true |
| 1879 | 1879 | }, |
| 1880 | 1880 | <?php |
| 1881 | - foreach ( $this->arguments as $key => $args ) { |
|
| 1882 | - $this->build_block_arguments( $key, $args ); |
|
| 1881 | + foreach ($this->arguments as $key => $args) { |
|
| 1882 | + $this->build_block_arguments($key, $args); |
|
| 1883 | 1883 | } |
| 1884 | 1884 | ?> |
| 1885 | 1885 | ), |
@@ -1893,9 +1893,9 @@ discard block |
||
| 1893 | 1893 | |
| 1894 | 1894 | <?php |
| 1895 | 1895 | // If the user sets block-output array then build it |
| 1896 | - if ( ! empty( $this->options['block-output'] ) ) { |
|
| 1897 | - $this->block_element( $this->options['block-output'] ); |
|
| 1898 | - }else{ |
|
| 1896 | + if (!empty($this->options['block-output'])) { |
|
| 1897 | + $this->block_element($this->options['block-output']); |
|
| 1898 | + } else { |
|
| 1899 | 1899 | // if no block-output is set then we try and get the shortcode html output via ajax. |
| 1900 | 1900 | ?> |
| 1901 | 1901 | el('div', { |
@@ -1919,19 +1919,19 @@ discard block |
||
| 1919 | 1919 | var align = ''; |
| 1920 | 1920 | |
| 1921 | 1921 | // build the shortcode. |
| 1922 | - var content = "[<?php echo $this->options['base_id'];?>"; |
|
| 1922 | + var content = "[<?php echo $this->options['base_id']; ?>"; |
|
| 1923 | 1923 | $html = ''; |
| 1924 | 1924 | <?php |
| 1925 | 1925 | |
| 1926 | - if(! empty( $this->arguments )){ |
|
| 1926 | + if (!empty($this->arguments)) { |
|
| 1927 | 1927 | |
| 1928 | - foreach($this->arguments as $key => $args){ |
|
| 1928 | + foreach ($this->arguments as $key => $args) { |
|
| 1929 | 1929 | ?> |
| 1930 | - if (attr.hasOwnProperty("<?php echo esc_attr( $key );?>")) { |
|
| 1931 | - if ('<?php echo esc_attr( $key );?>' == 'html') { |
|
| 1932 | - $html = attr.<?php echo esc_attr( $key );?>; |
|
| 1930 | + if (attr.hasOwnProperty("<?php echo esc_attr($key); ?>")) { |
|
| 1931 | + if ('<?php echo esc_attr($key); ?>' == 'html') { |
|
| 1932 | + $html = attr.<?php echo esc_attr($key); ?>; |
|
| 1933 | 1933 | } else { |
| 1934 | - content += " <?php echo esc_attr( $key );?>='" + attr.<?php echo esc_attr( $key );?>+ "' "; |
|
| 1934 | + content += " <?php echo esc_attr($key); ?>='" + attr.<?php echo esc_attr($key); ?>+ "' "; |
|
| 1935 | 1935 | } |
| 1936 | 1936 | } |
| 1937 | 1937 | <?php |
@@ -1943,7 +1943,7 @@ discard block |
||
| 1943 | 1943 | |
| 1944 | 1944 | // if has html element |
| 1945 | 1945 | if ($html) { |
| 1946 | - content += $html + "[/<?php echo $this->options['base_id'];?>]"; |
|
| 1946 | + content += $html + "[/<?php echo $this->options['base_id']; ?>]"; |
|
| 1947 | 1947 | } |
| 1948 | 1948 | |
| 1949 | 1949 | |
@@ -1961,11 +1961,11 @@ discard block |
||
| 1961 | 1961 | } |
| 1962 | 1962 | |
| 1963 | 1963 | <?php |
| 1964 | - if(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){ |
|
| 1964 | + if (isset($this->options['block-wrap']) && $this->options['block-wrap'] == '') { |
|
| 1965 | 1965 | ?> |
| 1966 | 1966 | return content; |
| 1967 | 1967 | <?php |
| 1968 | - }else{ |
|
| 1968 | + } else { |
|
| 1969 | 1969 | ?> |
| 1970 | 1970 | var block_wrap = 'div'; |
| 1971 | 1971 | if (attr.hasOwnProperty("block_wrap")) { |
@@ -1988,82 +1988,82 @@ discard block |
||
| 1988 | 1988 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
| 1989 | 1989 | */ |
| 1990 | 1990 | |
| 1991 | - return str_replace( array( |
|
| 1991 | + return str_replace(array( |
|
| 1992 | 1992 | '<script>', |
| 1993 | 1993 | '</script>' |
| 1994 | - ), '', $output ); |
|
| 1994 | + ), '', $output); |
|
| 1995 | 1995 | } |
| 1996 | 1996 | |
| 1997 | - public function build_block_arguments( $key, $args ) { |
|
| 1998 | - $custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : ''; |
|
| 1997 | + public function build_block_arguments($key, $args) { |
|
| 1998 | + $custom_attributes = !empty($args['custom_attributes']) ? $this->array_to_attributes($args['custom_attributes']) : ''; |
|
| 1999 | 1999 | $options = ''; |
| 2000 | 2000 | $extra = ''; |
| 2001 | 2001 | $require = ''; |
| 2002 | 2002 | |
| 2003 | 2003 | // `content` is a protected and special argument |
| 2004 | - if ( $key == 'content' ) { |
|
| 2004 | + if ($key == 'content') { |
|
| 2005 | 2005 | return; |
| 2006 | 2006 | } |
| 2007 | 2007 | |
| 2008 | 2008 | $onchange = "props.setAttributes({ $key: $key } )"; |
| 2009 | 2009 | $value = "props.attributes.$key"; |
| 2010 | - $text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'color' ); |
|
| 2011 | - if ( in_array( $args['type'], $text_type ) ) { |
|
| 2010 | + $text_type = array('text', 'password', 'number', 'email', 'tel', 'url', 'color'); |
|
| 2011 | + if (in_array($args['type'], $text_type)) { |
|
| 2012 | 2012 | $type = 'TextControl'; |
| 2013 | 2013 | // Save numbers as numbers and not strings |
| 2014 | - if ( $args['type'] == 'number' ) { |
|
| 2014 | + if ($args['type'] == 'number') { |
|
| 2015 | 2015 | $onchange = "props.setAttributes({ $key: Number($key) } )"; |
| 2016 | 2016 | } |
| 2017 | 2017 | } |
| 2018 | 2018 | // elseif ( $args['type'] == 'color' ) { //@todo ColorPicker labels are not shown yet, we use html5 color input for now https://github.com/WordPress/gutenberg/issues/14378 |
| 2019 | 2019 | // $type = 'ColorPicker'; |
| 2020 | 2020 | // } |
| 2021 | - elseif ( $args['type'] == 'checkbox' ) { |
|
| 2021 | + elseif ($args['type'] == 'checkbox') { |
|
| 2022 | 2022 | $type = 'CheckboxControl'; |
| 2023 | 2023 | $extra .= "checked: props.attributes.$key,"; |
| 2024 | 2024 | $onchange = "props.setAttributes({ $key: ! props.attributes.$key } )"; |
| 2025 | - } elseif ( $args['type'] == 'textarea' ) { |
|
| 2025 | + } elseif ($args['type'] == 'textarea') { |
|
| 2026 | 2026 | $type = 'TextareaControl'; |
| 2027 | - } elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) { |
|
| 2027 | + } elseif ($args['type'] == 'select' || $args['type'] == 'multiselect') { |
|
| 2028 | 2028 | $type = 'SelectControl'; |
| 2029 | - if ( ! empty( $args['options'] ) ) { |
|
| 2029 | + if (!empty($args['options'])) { |
|
| 2030 | 2030 | $options .= "options: ["; |
| 2031 | - foreach ( $args['options'] as $option_val => $option_label ) { |
|
| 2032 | - $options .= "{ value: '" . esc_attr( $option_val ) . "', label: '" . addslashes( $option_label ) . "' },"; |
|
| 2031 | + foreach ($args['options'] as $option_val => $option_label) { |
|
| 2032 | + $options .= "{ value: '" . esc_attr($option_val) . "', label: '" . addslashes($option_label) . "' },"; |
|
| 2033 | 2033 | } |
| 2034 | 2034 | $options .= "],"; |
| 2035 | 2035 | } |
| 2036 | - if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550 |
|
| 2036 | + if (isset($args['multiple']) && $args['multiple']) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550 |
|
| 2037 | 2037 | $extra .= ' multiple: true, '; |
| 2038 | 2038 | //$onchange = "props.setAttributes({ $key: ['edit'] } )"; |
| 2039 | 2039 | //$value = "['edit', 'delete']"; |
| 2040 | 2040 | } |
| 2041 | - } elseif ( $args['type'] == 'alignment' ) { |
|
| 2041 | + } elseif ($args['type'] == 'alignment') { |
|
| 2042 | 2042 | $type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example |
| 2043 | 2043 | } else { |
| 2044 | - return;// if we have not implemented the control then don't break the JS. |
|
| 2044 | + return; // if we have not implemented the control then don't break the JS. |
|
| 2045 | 2045 | } |
| 2046 | 2046 | |
| 2047 | 2047 | // add show only if advanced |
| 2048 | - if ( ! empty( $args['advanced'] ) ) { |
|
| 2048 | + if (!empty($args['advanced'])) { |
|
| 2049 | 2049 | echo "props.attributes.show_advanced && "; |
| 2050 | 2050 | } |
| 2051 | 2051 | // add setting require if defined |
| 2052 | - if ( ! empty( $args['element_require'] ) ) { |
|
| 2053 | - echo $this->block_props_replace( $args['element_require'], true ) . " && "; |
|
| 2052 | + if (!empty($args['element_require'])) { |
|
| 2053 | + echo $this->block_props_replace($args['element_require'], true) . " && "; |
|
| 2054 | 2054 | } |
| 2055 | 2055 | ?> |
| 2056 | 2056 | el( wp.components.<?php echo $type; ?>, { |
| 2057 | - label: '<?php echo addslashes( $args['title'] ); ?>', |
|
| 2058 | - help: '<?php if ( isset( $args['desc'] ) ) { |
|
| 2059 | - echo addslashes( $args['desc'] ); |
|
| 2057 | + label: '<?php echo addslashes($args['title']); ?>', |
|
| 2058 | + help: '<?php if (isset($args['desc'])) { |
|
| 2059 | + echo addslashes($args['desc']); |
|
| 2060 | 2060 | } ?>', |
| 2061 | 2061 | value: <?php echo $value; ?>, |
| 2062 | - <?php if ( $type == 'TextControl' && $args['type'] != 'text' ) { |
|
| 2063 | - echo "type: '" . addslashes( $args['type'] ) . "',"; |
|
| 2062 | + <?php if ($type == 'TextControl' && $args['type'] != 'text') { |
|
| 2063 | + echo "type: '" . addslashes($args['type']) . "',"; |
|
| 2064 | 2064 | } ?> |
| 2065 | - <?php if ( ! empty( $args['placeholder'] ) ) { |
|
| 2066 | - echo "placeholder: '" . addslashes( $args['placeholder'] ) . "',"; |
|
| 2065 | + <?php if (!empty($args['placeholder'])) { |
|
| 2066 | + echo "placeholder: '" . addslashes($args['placeholder']) . "',"; |
|
| 2067 | 2067 | } ?> |
| 2068 | 2068 | <?php echo $options; ?> |
| 2069 | 2069 | <?php echo $extra; ?> |
@@ -2084,16 +2084,16 @@ discard block |
||
| 2084 | 2084 | * |
| 2085 | 2085 | * @return string |
| 2086 | 2086 | */ |
| 2087 | - public function array_to_attributes( $custom_attributes, $html = false ) { |
|
| 2087 | + public function array_to_attributes($custom_attributes, $html = false) { |
|
| 2088 | 2088 | $attributes = ''; |
| 2089 | - if ( ! empty( $custom_attributes ) ) { |
|
| 2089 | + if (!empty($custom_attributes)) { |
|
| 2090 | 2090 | |
| 2091 | - if ( $html ) { |
|
| 2092 | - foreach ( $custom_attributes as $key => $val ) { |
|
| 2091 | + if ($html) { |
|
| 2092 | + foreach ($custom_attributes as $key => $val) { |
|
| 2093 | 2093 | $attributes .= " $key='$val' "; |
| 2094 | 2094 | } |
| 2095 | 2095 | } else { |
| 2096 | - foreach ( $custom_attributes as $key => $val ) { |
|
| 2096 | + foreach ($custom_attributes as $key => $val) { |
|
| 2097 | 2097 | $attributes .= "'$key': '$val',"; |
| 2098 | 2098 | } |
| 2099 | 2099 | } |
@@ -2109,86 +2109,86 @@ discard block |
||
| 2109 | 2109 | * |
| 2110 | 2110 | * @param $args |
| 2111 | 2111 | */ |
| 2112 | - public function block_element( $args ) { |
|
| 2112 | + public function block_element($args) { |
|
| 2113 | 2113 | |
| 2114 | 2114 | |
| 2115 | - if ( ! empty( $args ) ) { |
|
| 2116 | - foreach ( $args as $element => $new_args ) { |
|
| 2115 | + if (!empty($args)) { |
|
| 2116 | + foreach ($args as $element => $new_args) { |
|
| 2117 | 2117 | |
| 2118 | - if ( is_array( $new_args ) ) { // its an element |
|
| 2118 | + if (is_array($new_args)) { // its an element |
|
| 2119 | 2119 | |
| 2120 | 2120 | |
| 2121 | - if ( isset( $new_args['element'] ) ) { |
|
| 2121 | + if (isset($new_args['element'])) { |
|
| 2122 | 2122 | |
| 2123 | - if ( isset( $new_args['element_require'] ) ) { |
|
| 2124 | - echo str_replace( array( |
|
| 2123 | + if (isset($new_args['element_require'])) { |
|
| 2124 | + echo str_replace(array( |
|
| 2125 | 2125 | "'+", |
| 2126 | 2126 | "+'" |
| 2127 | - ), '', $this->block_props_replace( $new_args['element_require'] ) ) . " && "; |
|
| 2128 | - unset( $new_args['element_require'] ); |
|
| 2127 | + ), '', $this->block_props_replace($new_args['element_require'])) . " && "; |
|
| 2128 | + unset($new_args['element_require']); |
|
| 2129 | 2129 | } |
| 2130 | 2130 | |
| 2131 | 2131 | echo "\n el( '" . $new_args['element'] . "', {"; |
| 2132 | 2132 | |
| 2133 | 2133 | // get the attributes |
| 2134 | - foreach ( $new_args as $new_key => $new_value ) { |
|
| 2134 | + foreach ($new_args as $new_key => $new_value) { |
|
| 2135 | 2135 | |
| 2136 | 2136 | |
| 2137 | - if ( $new_key == 'element' || $new_key == 'content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) { |
|
| 2137 | + if ($new_key == 'element' || $new_key == 'content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array($new_value)) { |
|
| 2138 | 2138 | // do nothing |
| 2139 | 2139 | } else { |
| 2140 | - echo $this->block_element( array( $new_key => $new_value ) ); |
|
| 2140 | + echo $this->block_element(array($new_key => $new_value)); |
|
| 2141 | 2141 | } |
| 2142 | 2142 | } |
| 2143 | 2143 | |
| 2144 | - echo "},";// end attributes |
|
| 2144 | + echo "},"; // end attributes |
|
| 2145 | 2145 | |
| 2146 | 2146 | // get the content |
| 2147 | 2147 | $first_item = 0; |
| 2148 | - foreach ( $new_args as $new_key => $new_value ) { |
|
| 2149 | - if ( $new_key === 'content' || is_array( $new_value ) ) { |
|
| 2148 | + foreach ($new_args as $new_key => $new_value) { |
|
| 2149 | + if ($new_key === 'content' || is_array($new_value)) { |
|
| 2150 | 2150 | |
| 2151 | - if ( $new_key === 'content' ) { |
|
| 2152 | - echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'"; |
|
| 2151 | + if ($new_key === 'content') { |
|
| 2152 | + echo "'" . $this->block_props_replace(wp_slash($new_value)) . "'"; |
|
| 2153 | 2153 | } |
| 2154 | 2154 | |
| 2155 | - if ( is_array( $new_value ) ) { |
|
| 2155 | + if (is_array($new_value)) { |
|
| 2156 | 2156 | |
| 2157 | - if ( isset( $new_value['element_require'] ) ) { |
|
| 2158 | - echo str_replace( array( |
|
| 2157 | + if (isset($new_value['element_require'])) { |
|
| 2158 | + echo str_replace(array( |
|
| 2159 | 2159 | "'+", |
| 2160 | 2160 | "+'" |
| 2161 | - ), '', $this->block_props_replace( $new_value['element_require'] ) ) . " && "; |
|
| 2162 | - unset( $new_value['element_require'] ); |
|
| 2161 | + ), '', $this->block_props_replace($new_value['element_require'])) . " && "; |
|
| 2162 | + unset($new_value['element_require']); |
|
| 2163 | 2163 | } |
| 2164 | 2164 | |
| 2165 | - if ( isset( $new_value['element_repeat'] ) ) { |
|
| 2165 | + if (isset($new_value['element_repeat'])) { |
|
| 2166 | 2166 | $x = 1; |
| 2167 | - while ( $x <= absint( $new_value['element_repeat'] ) ) { |
|
| 2168 | - $this->block_element( array( '' => $new_value ) ); |
|
| 2169 | - $x ++; |
|
| 2167 | + while ($x <= absint($new_value['element_repeat'])) { |
|
| 2168 | + $this->block_element(array('' => $new_value)); |
|
| 2169 | + $x++; |
|
| 2170 | 2170 | } |
| 2171 | 2171 | } else { |
| 2172 | - $this->block_element( array( '' => $new_value ) ); |
|
| 2172 | + $this->block_element(array('' => $new_value)); |
|
| 2173 | 2173 | } |
| 2174 | 2174 | } |
| 2175 | - $first_item ++; |
|
| 2175 | + $first_item++; |
|
| 2176 | 2176 | } |
| 2177 | 2177 | } |
| 2178 | 2178 | |
| 2179 | - echo ")";// end content |
|
| 2179 | + echo ")"; // end content |
|
| 2180 | 2180 | |
| 2181 | 2181 | echo ", \n"; |
| 2182 | 2182 | |
| 2183 | 2183 | } |
| 2184 | 2184 | } else { |
| 2185 | 2185 | |
| 2186 | - if ( substr( $element, 0, 3 ) === "if_" ) { |
|
| 2187 | - echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ","; |
|
| 2188 | - } elseif ( $element == 'style' ) { |
|
| 2189 | - echo $element . ": " . $this->block_props_replace( $new_args ) . ","; |
|
| 2186 | + if (substr($element, 0, 3) === "if_") { |
|
| 2187 | + echo str_replace("if_", "", $element) . ": " . $this->block_props_replace($new_args, true) . ","; |
|
| 2188 | + } elseif ($element == 'style') { |
|
| 2189 | + echo $element . ": " . $this->block_props_replace($new_args) . ","; |
|
| 2190 | 2190 | } else { |
| 2191 | - echo $element . ": '" . $this->block_props_replace( $new_args ) . "',"; |
|
| 2191 | + echo $element . ": '" . $this->block_props_replace($new_args) . "',"; |
|
| 2192 | 2192 | } |
| 2193 | 2193 | |
| 2194 | 2194 | } |
@@ -2203,12 +2203,12 @@ discard block |
||
| 2203 | 2203 | * |
| 2204 | 2204 | * @return mixed |
| 2205 | 2205 | */ |
| 2206 | - public function block_props_replace( $string, $no_wrap = false ) { |
|
| 2206 | + public function block_props_replace($string, $no_wrap = false) { |
|
| 2207 | 2207 | |
| 2208 | - if ( $no_wrap ) { |
|
| 2209 | - $string = str_replace( array( "[%", "%]" ), array( "props.attributes.", "" ), $string ); |
|
| 2208 | + if ($no_wrap) { |
|
| 2209 | + $string = str_replace(array("[%", "%]"), array("props.attributes.", ""), $string); |
|
| 2210 | 2210 | } else { |
| 2211 | - $string = str_replace( array( "[%", "%]" ), array( "'+props.attributes.", "+'" ), $string ); |
|
| 2211 | + $string = str_replace(array("[%", "%]"), array("'+props.attributes.", "+'"), $string); |
|
| 2212 | 2212 | } |
| 2213 | 2213 | |
| 2214 | 2214 | return $string; |
@@ -2220,50 +2220,50 @@ discard block |
||
| 2220 | 2220 | * @param array $args |
| 2221 | 2221 | * @param array $instance |
| 2222 | 2222 | */ |
| 2223 | - public function widget( $args, $instance ) { |
|
| 2223 | + public function widget($args, $instance) { |
|
| 2224 | 2224 | |
| 2225 | 2225 | // get the filtered values |
| 2226 | - $argument_values = $this->argument_values( $instance ); |
|
| 2227 | - $argument_values = $this->string_to_bool( $argument_values ); |
|
| 2228 | - $output = $this->output( $argument_values, $args ); |
|
| 2226 | + $argument_values = $this->argument_values($instance); |
|
| 2227 | + $argument_values = $this->string_to_bool($argument_values); |
|
| 2228 | + $output = $this->output($argument_values, $args); |
|
| 2229 | 2229 | |
| 2230 | 2230 | $no_wrap = false; |
| 2231 | - if ( isset( $argument_values['no_wrap'] ) && $argument_values['no_wrap'] ) { |
|
| 2231 | + if (isset($argument_values['no_wrap']) && $argument_values['no_wrap']) { |
|
| 2232 | 2232 | $no_wrap = true; |
| 2233 | 2233 | } |
| 2234 | 2234 | |
| 2235 | 2235 | ob_start(); |
| 2236 | - if ( $output && ! $no_wrap ) { |
|
| 2236 | + if ($output && !$no_wrap) { |
|
| 2237 | 2237 | // Before widget |
| 2238 | 2238 | $before_widget = $args['before_widget']; |
| 2239 | - $before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this ); |
|
| 2240 | - $before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this ); |
|
| 2239 | + $before_widget = apply_filters('wp_super_duper_before_widget', $before_widget, $args, $instance, $this); |
|
| 2240 | + $before_widget = apply_filters('wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this); |
|
| 2241 | 2241 | |
| 2242 | 2242 | // After widget |
| 2243 | 2243 | $after_widget = $args['after_widget']; |
| 2244 | - $after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this ); |
|
| 2245 | - $after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this ); |
|
| 2244 | + $after_widget = apply_filters('wp_super_duper_after_widget', $after_widget, $args, $instance, $this); |
|
| 2245 | + $after_widget = apply_filters('wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this); |
|
| 2246 | 2246 | |
| 2247 | 2247 | echo $before_widget; |
| 2248 | 2248 | // elementor strips the widget wrapping div so we check for and add it back if needed |
| 2249 | - if ( $this->is_elementor_widget_output() ) { |
|
| 2250 | - echo ! empty( $this->options['widget_ops']['classname'] ) ? "<span class='" . esc_attr( $this->options['widget_ops']['classname'] ) . "'>" : ''; |
|
| 2249 | + if ($this->is_elementor_widget_output()) { |
|
| 2250 | + echo !empty($this->options['widget_ops']['classname']) ? "<span class='" . esc_attr($this->options['widget_ops']['classname']) . "'>" : ''; |
|
| 2251 | 2251 | } |
| 2252 | - echo $this->output_title( $args, $instance ); |
|
| 2252 | + echo $this->output_title($args, $instance); |
|
| 2253 | 2253 | echo $output; |
| 2254 | - if ( $this->is_elementor_widget_output() ) { |
|
| 2255 | - echo ! empty( $this->options['widget_ops']['classname'] ) ? "</span>" : ''; |
|
| 2254 | + if ($this->is_elementor_widget_output()) { |
|
| 2255 | + echo !empty($this->options['widget_ops']['classname']) ? "</span>" : ''; |
|
| 2256 | 2256 | } |
| 2257 | 2257 | echo $after_widget; |
| 2258 | - } elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty |
|
| 2259 | - $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" ); |
|
| 2258 | + } elseif ($this->is_preview() && $output == '') {// if preview show a placeholder if empty |
|
| 2259 | + $output = $this->preview_placeholder_text("{{" . $this->base_id . "}}"); |
|
| 2260 | 2260 | echo $output; |
| 2261 | - } elseif ( $output && $no_wrap ) { |
|
| 2261 | + } elseif ($output && $no_wrap) { |
|
| 2262 | 2262 | echo $output; |
| 2263 | 2263 | } |
| 2264 | 2264 | $output = ob_get_clean(); |
| 2265 | 2265 | |
| 2266 | - $output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this ); |
|
| 2266 | + $output = apply_filters('wp_super_duper_widget_output', $output, $instance, $args, $this); |
|
| 2267 | 2267 | |
| 2268 | 2268 | echo $output; |
| 2269 | 2269 | } |
@@ -2276,7 +2276,7 @@ discard block |
||
| 2276 | 2276 | */ |
| 2277 | 2277 | public function is_elementor_widget_output() { |
| 2278 | 2278 | $result = false; |
| 2279 | - if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) { |
|
| 2279 | + if (defined('ELEMENTOR_VERSION') && isset($this->number) && $this->number == 'REPLACE_TO_ID') { |
|
| 2280 | 2280 | $result = true; |
| 2281 | 2281 | } |
| 2282 | 2282 | |
@@ -2291,7 +2291,7 @@ discard block |
||
| 2291 | 2291 | */ |
| 2292 | 2292 | public function is_elementor_preview() { |
| 2293 | 2293 | $result = false; |
| 2294 | - if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) { |
|
| 2294 | + if (isset($_REQUEST['elementor-preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor') || (isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor_ajax')) { |
|
| 2295 | 2295 | $result = true; |
| 2296 | 2296 | } |
| 2297 | 2297 | |
@@ -2306,7 +2306,7 @@ discard block |
||
| 2306 | 2306 | */ |
| 2307 | 2307 | public function is_divi_preview() { |
| 2308 | 2308 | $result = false; |
| 2309 | - if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) { |
|
| 2309 | + if (isset($_REQUEST['et_fb']) || isset($_REQUEST['et_pb_preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor')) { |
|
| 2310 | 2310 | $result = true; |
| 2311 | 2311 | } |
| 2312 | 2312 | |
@@ -2321,7 +2321,7 @@ discard block |
||
| 2321 | 2321 | */ |
| 2322 | 2322 | public function is_beaver_preview() { |
| 2323 | 2323 | $result = false; |
| 2324 | - if ( isset( $_REQUEST['fl_builder'] ) ) { |
|
| 2324 | + if (isset($_REQUEST['fl_builder'])) { |
|
| 2325 | 2325 | $result = true; |
| 2326 | 2326 | } |
| 2327 | 2327 | |
@@ -2336,7 +2336,7 @@ discard block |
||
| 2336 | 2336 | */ |
| 2337 | 2337 | public function is_siteorigin_preview() { |
| 2338 | 2338 | $result = false; |
| 2339 | - if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) { |
|
| 2339 | + if (!empty($_REQUEST['siteorigin_panels_live_editor'])) { |
|
| 2340 | 2340 | $result = true; |
| 2341 | 2341 | } |
| 2342 | 2342 | |
@@ -2351,7 +2351,7 @@ discard block |
||
| 2351 | 2351 | */ |
| 2352 | 2352 | public function is_cornerstone_preview() { |
| 2353 | 2353 | $result = false; |
| 2354 | - if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) { |
|
| 2354 | + if (!empty($_REQUEST['cornerstone_preview']) || basename($_SERVER['REQUEST_URI']) == 'cornerstone-endpoint') { |
|
| 2355 | 2355 | $result = true; |
| 2356 | 2356 | } |
| 2357 | 2357 | |
@@ -2366,7 +2366,7 @@ discard block |
||
| 2366 | 2366 | */ |
| 2367 | 2367 | public function is_fusion_preview() { |
| 2368 | 2368 | $result = false; |
| 2369 | - if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) { |
|
| 2369 | + if (!empty($_REQUEST['fb-edit']) || !empty($_REQUEST['fusion_load_nonce'])) { |
|
| 2370 | 2370 | $result = true; |
| 2371 | 2371 | } |
| 2372 | 2372 | |
@@ -2381,7 +2381,7 @@ discard block |
||
| 2381 | 2381 | */ |
| 2382 | 2382 | public function is_oxygen_preview() { |
| 2383 | 2383 | $result = false; |
| 2384 | - if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) { |
|
| 2384 | + if (!empty($_REQUEST['ct_builder']) || (!empty($_REQUEST['action']) && (substr($_REQUEST['action'], 0, 11) === "oxy_render_" || substr($_REQUEST['action'], 0, 10) === "ct_render_"))) { |
|
| 2385 | 2385 | $result = true; |
| 2386 | 2386 | } |
| 2387 | 2387 | |
@@ -2396,19 +2396,19 @@ discard block |
||
| 2396 | 2396 | */ |
| 2397 | 2397 | public function is_preview() { |
| 2398 | 2398 | $preview = false; |
| 2399 | - if ( $this->is_divi_preview() ) { |
|
| 2399 | + if ($this->is_divi_preview()) { |
|
| 2400 | 2400 | $preview = true; |
| 2401 | - } elseif ( $this->is_elementor_preview() ) { |
|
| 2401 | + } elseif ($this->is_elementor_preview()) { |
|
| 2402 | 2402 | $preview = true; |
| 2403 | - } elseif ( $this->is_beaver_preview() ) { |
|
| 2403 | + } elseif ($this->is_beaver_preview()) { |
|
| 2404 | 2404 | $preview = true; |
| 2405 | - } elseif ( $this->is_siteorigin_preview() ) { |
|
| 2405 | + } elseif ($this->is_siteorigin_preview()) { |
|
| 2406 | 2406 | $preview = true; |
| 2407 | - } elseif ( $this->is_cornerstone_preview() ) { |
|
| 2407 | + } elseif ($this->is_cornerstone_preview()) { |
|
| 2408 | 2408 | $preview = true; |
| 2409 | - } elseif ( $this->is_fusion_preview() ) { |
|
| 2409 | + } elseif ($this->is_fusion_preview()) { |
|
| 2410 | 2410 | $preview = true; |
| 2411 | - } elseif ( $this->is_oxygen_preview() ) { |
|
| 2411 | + } elseif ($this->is_oxygen_preview()) { |
|
| 2412 | 2412 | $preview = true; |
| 2413 | 2413 | } |
| 2414 | 2414 | |
@@ -2423,11 +2423,11 @@ discard block |
||
| 2423 | 2423 | * |
| 2424 | 2424 | * @return string |
| 2425 | 2425 | */ |
| 2426 | - public function output_title( $args, $instance = array() ) { |
|
| 2426 | + public function output_title($args, $instance = array()) { |
|
| 2427 | 2427 | $output = ''; |
| 2428 | - if ( ! empty( $instance['title'] ) ) { |
|
| 2428 | + if (!empty($instance['title'])) { |
|
| 2429 | 2429 | /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ |
| 2430 | - $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); |
|
| 2430 | + $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base); |
|
| 2431 | 2431 | $output = $args['before_title'] . $title . $args['after_title']; |
| 2432 | 2432 | } |
| 2433 | 2433 | |
@@ -2439,7 +2439,7 @@ discard block |
||
| 2439 | 2439 | * |
| 2440 | 2440 | * @param array $instance The widget options. |
| 2441 | 2441 | */ |
| 2442 | - public function form( $instance ) { |
|
| 2442 | + public function form($instance) { |
|
| 2443 | 2443 | |
| 2444 | 2444 | // set widget instance |
| 2445 | 2445 | $this->instance = $instance; |
@@ -2447,20 +2447,20 @@ discard block |
||
| 2447 | 2447 | // set it as a SD widget |
| 2448 | 2448 | echo $this->widget_advanced_toggle(); |
| 2449 | 2449 | |
| 2450 | - echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>"; |
|
| 2450 | + echo "<p>" . esc_attr($this->options['widget_ops']['description']) . "</p>"; |
|
| 2451 | 2451 | $arguments_raw = $this->get_arguments(); |
| 2452 | 2452 | |
| 2453 | - if ( is_array( $arguments_raw ) ) { |
|
| 2453 | + if (is_array($arguments_raw)) { |
|
| 2454 | 2454 | |
| 2455 | - $arguments = $this->group_arguments( $arguments_raw ); |
|
| 2455 | + $arguments = $this->group_arguments($arguments_raw); |
|
| 2456 | 2456 | |
| 2457 | 2457 | // Do we have sections? |
| 2458 | 2458 | $has_sections = $arguments == $arguments_raw ? false : true; |
| 2459 | 2459 | |
| 2460 | 2460 | |
| 2461 | - if ( $has_sections ) { |
|
| 2461 | + if ($has_sections) { |
|
| 2462 | 2462 | $panel_count = 0; |
| 2463 | - foreach ( $arguments as $key => $args ) { |
|
| 2463 | + foreach ($arguments as $key => $args) { |
|
| 2464 | 2464 | |
| 2465 | 2465 | ?> |
| 2466 | 2466 | <script> |
@@ -2470,21 +2470,21 @@ discard block |
||
| 2470 | 2470 | |
| 2471 | 2471 | $hide = $panel_count ? ' style="display:none;" ' : ''; |
| 2472 | 2472 | $icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down'; |
| 2473 | - echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes( $key ) . "'>" . esc_attr( $key ) . " <i style='float:right;' class='" . $icon_class . "'></i></button>"; |
|
| 2474 | - echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>"; |
|
| 2473 | + echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes($key) . "'>" . esc_attr($key) . " <i style='float:right;' class='" . $icon_class . "'></i></button>"; |
|
| 2474 | + echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes($key) . "' $hide>"; |
|
| 2475 | 2475 | |
| 2476 | - foreach ( $args as $k => $a ) { |
|
| 2477 | - $this->widget_inputs( $a, $instance ); |
|
| 2476 | + foreach ($args as $k => $a) { |
|
| 2477 | + $this->widget_inputs($a, $instance); |
|
| 2478 | 2478 | } |
| 2479 | 2479 | |
| 2480 | 2480 | echo "</div>"; |
| 2481 | 2481 | |
| 2482 | - $panel_count ++; |
|
| 2482 | + $panel_count++; |
|
| 2483 | 2483 | |
| 2484 | 2484 | } |
| 2485 | 2485 | } else { |
| 2486 | - foreach ( $arguments as $key => $args ) { |
|
| 2487 | - $this->widget_inputs( $args, $instance ); |
|
| 2486 | + foreach ($arguments as $key => $args) { |
|
| 2487 | + $this->widget_inputs($args, $instance); |
|
| 2488 | 2488 | } |
| 2489 | 2489 | } |
| 2490 | 2490 | |
@@ -2499,7 +2499,7 @@ discard block |
||
| 2499 | 2499 | public function widget_advanced_toggle() { |
| 2500 | 2500 | |
| 2501 | 2501 | $output = ''; |
| 2502 | - if ( $this->block_show_advanced() ) { |
|
| 2502 | + if ($this->block_show_advanced()) { |
|
| 2503 | 2503 | $val = 1; |
| 2504 | 2504 | } else { |
| 2505 | 2505 | $val = 0; |
@@ -2519,14 +2519,14 @@ discard block |
||
| 2519 | 2519 | * |
| 2520 | 2520 | * @return string $output |
| 2521 | 2521 | */ |
| 2522 | - public function convert_element_require( $input ) { |
|
| 2522 | + public function convert_element_require($input) { |
|
| 2523 | 2523 | |
| 2524 | - $input = str_replace( "'", '"', $input );// we only want double quotes |
|
| 2524 | + $input = str_replace("'", '"', $input); // we only want double quotes |
|
| 2525 | 2525 | |
| 2526 | - $output = esc_attr( str_replace( array( "[%", "%]" ), array( |
|
| 2526 | + $output = esc_attr(str_replace(array("[%", "%]"), array( |
|
| 2527 | 2527 | "jQuery(form).find('[data-argument=\"", |
| 2528 | 2528 | "\"]').find('input,select,textarea').val()" |
| 2529 | - ), $input ) ); |
|
| 2529 | + ), $input)); |
|
| 2530 | 2530 | |
| 2531 | 2531 | return $output; |
| 2532 | 2532 | } |
@@ -2537,54 +2537,54 @@ discard block |
||
| 2537 | 2537 | * @param $args |
| 2538 | 2538 | * @param $instance |
| 2539 | 2539 | */ |
| 2540 | - public function widget_inputs( $args, $instance ) { |
|
| 2540 | + public function widget_inputs($args, $instance) { |
|
| 2541 | 2541 | |
| 2542 | 2542 | $class = ""; |
| 2543 | 2543 | $element_require = ""; |
| 2544 | 2544 | $custom_attributes = ""; |
| 2545 | 2545 | |
| 2546 | 2546 | // get value |
| 2547 | - if ( isset( $instance[ $args['name'] ] ) ) { |
|
| 2548 | - $value = $instance[ $args['name'] ]; |
|
| 2549 | - } elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) { |
|
| 2550 | - $value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] ); |
|
| 2547 | + if (isset($instance[$args['name']])) { |
|
| 2548 | + $value = $instance[$args['name']]; |
|
| 2549 | + } elseif (!isset($instance[$args['name']]) && !empty($args['default'])) { |
|
| 2550 | + $value = is_array($args['default']) ? array_map("esc_html", $args['default']) : esc_html($args['default']); |
|
| 2551 | 2551 | } else { |
| 2552 | 2552 | $value = ''; |
| 2553 | 2553 | } |
| 2554 | 2554 | |
| 2555 | 2555 | // get placeholder |
| 2556 | - if ( ! empty( $args['placeholder'] ) ) { |
|
| 2557 | - $placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'"; |
|
| 2556 | + if (!empty($args['placeholder'])) { |
|
| 2557 | + $placeholder = "placeholder='" . esc_html($args['placeholder']) . "'"; |
|
| 2558 | 2558 | } else { |
| 2559 | 2559 | $placeholder = ''; |
| 2560 | 2560 | } |
| 2561 | 2561 | |
| 2562 | 2562 | // get if advanced |
| 2563 | - if ( isset( $args['advanced'] ) && $args['advanced'] ) { |
|
| 2563 | + if (isset($args['advanced']) && $args['advanced']) { |
|
| 2564 | 2564 | $class .= " sd-advanced-setting "; |
| 2565 | 2565 | } |
| 2566 | 2566 | |
| 2567 | 2567 | // element_require |
| 2568 | - if ( isset( $args['element_require'] ) && $args['element_require'] ) { |
|
| 2568 | + if (isset($args['element_require']) && $args['element_require']) { |
|
| 2569 | 2569 | $element_require = $args['element_require']; |
| 2570 | 2570 | } |
| 2571 | 2571 | |
| 2572 | 2572 | // custom_attributes |
| 2573 | - if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) { |
|
| 2574 | - $custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true ); |
|
| 2573 | + if (isset($args['custom_attributes']) && $args['custom_attributes']) { |
|
| 2574 | + $custom_attributes = $this->array_to_attributes($args['custom_attributes'], true); |
|
| 2575 | 2575 | } |
| 2576 | 2576 | |
| 2577 | 2577 | // before wrapper |
| 2578 | 2578 | ?> |
| 2579 | - <p class="sd-argument <?php echo esc_attr( $class ); ?>" |
|
| 2580 | - data-argument='<?php echo esc_attr( $args['name'] ); ?>' |
|
| 2581 | - data-element_require='<?php if ( $element_require ) { |
|
| 2582 | - echo $this->convert_element_require( $element_require ); |
|
| 2579 | + <p class="sd-argument <?php echo esc_attr($class); ?>" |
|
| 2580 | + data-argument='<?php echo esc_attr($args['name']); ?>' |
|
| 2581 | + data-element_require='<?php if ($element_require) { |
|
| 2582 | + echo $this->convert_element_require($element_require); |
|
| 2583 | 2583 | } ?>' |
| 2584 | 2584 | > |
| 2585 | 2585 | <?php |
| 2586 | 2586 | |
| 2587 | - switch ( $args['type'] ) { |
|
| 2587 | + switch ($args['type']) { |
|
| 2588 | 2588 | //array('text','password','number','email','tel','url','color') |
| 2589 | 2589 | case "text": |
| 2590 | 2590 | case "password": |
@@ -2595,46 +2595,46 @@ discard block |
||
| 2595 | 2595 | case "color": |
| 2596 | 2596 | ?> |
| 2597 | 2597 | <label |
| 2598 | - for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label> |
|
| 2598 | + for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo esc_attr($args['title']); ?><?php echo $this->widget_field_desc($args); ?></label> |
|
| 2599 | 2599 | <input <?php echo $placeholder; ?> class="widefat" |
| 2600 | 2600 | <?php echo $custom_attributes; ?> |
| 2601 | - id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
|
| 2602 | - name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" |
|
| 2603 | - type="<?php echo esc_attr( $args['type'] ); ?>" |
|
| 2604 | - value="<?php echo esc_attr( $value ); ?>"> |
|
| 2601 | + id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" |
|
| 2602 | + name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" |
|
| 2603 | + type="<?php echo esc_attr($args['type']); ?>" |
|
| 2604 | + value="<?php echo esc_attr($value); ?>"> |
|
| 2605 | 2605 | <?php |
| 2606 | 2606 | |
| 2607 | 2607 | break; |
| 2608 | 2608 | case "select": |
| 2609 | - $multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false; |
|
| 2610 | - if ( $multiple ) { |
|
| 2611 | - if ( empty( $value ) ) { |
|
| 2609 | + $multiple = isset($args['multiple']) && $args['multiple'] ? true : false; |
|
| 2610 | + if ($multiple) { |
|
| 2611 | + if (empty($value)) { |
|
| 2612 | 2612 | $value = array(); |
| 2613 | 2613 | } |
| 2614 | 2614 | } |
| 2615 | 2615 | ?> |
| 2616 | 2616 | <label |
| 2617 | - for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label> |
|
| 2617 | + for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo esc_attr($args['title']); ?><?php echo $this->widget_field_desc($args); ?></label> |
|
| 2618 | 2618 | <select <?php echo $placeholder; ?> class="widefat" |
| 2619 | 2619 | <?php echo $custom_attributes; ?> |
| 2620 | - id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
|
| 2621 | - name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); |
|
| 2622 | - if ( $multiple ) { |
|
| 2620 | + id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" |
|
| 2621 | + name="<?php echo esc_attr($this->get_field_name($args['name'])); |
|
| 2622 | + if ($multiple) { |
|
| 2623 | 2623 | echo "[]"; |
| 2624 | 2624 | } ?>" |
| 2625 | - <?php if ( $multiple ) { |
|
| 2625 | + <?php if ($multiple) { |
|
| 2626 | 2626 | echo "multiple"; |
| 2627 | 2627 | } //@todo not implemented yet due to gutenberg not supporting it |
| 2628 | 2628 | ?> |
| 2629 | 2629 | > |
| 2630 | 2630 | <?php |
| 2631 | 2631 | |
| 2632 | - if ( ! empty( $args['options'] ) ) { |
|
| 2633 | - foreach ( $args['options'] as $val => $label ) { |
|
| 2634 | - if ( $multiple ) { |
|
| 2635 | - $selected = in_array( $val, $value ) ? 'selected="selected"' : ''; |
|
| 2632 | + if (!empty($args['options'])) { |
|
| 2633 | + foreach ($args['options'] as $val => $label) { |
|
| 2634 | + if ($multiple) { |
|
| 2635 | + $selected = in_array($val, $value) ? 'selected="selected"' : ''; |
|
| 2636 | 2636 | } else { |
| 2637 | - $selected = selected( $value, $val, false ); |
|
| 2637 | + $selected = selected($value, $val, false); |
|
| 2638 | 2638 | } |
| 2639 | 2639 | echo "<option value='$val' " . $selected . ">$label</option>"; |
| 2640 | 2640 | } |
@@ -2646,32 +2646,32 @@ discard block |
||
| 2646 | 2646 | case "checkbox": |
| 2647 | 2647 | ?> |
| 2648 | 2648 | <input <?php echo $placeholder; ?> |
| 2649 | - <?php checked( 1, $value, true ) ?> |
|
| 2649 | + <?php checked(1, $value, true) ?> |
|
| 2650 | 2650 | <?php echo $custom_attributes; ?> |
| 2651 | - class="widefat" id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
|
| 2652 | - name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="checkbox" |
|
| 2651 | + class="widefat" id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" |
|
| 2652 | + name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" type="checkbox" |
|
| 2653 | 2653 | value="1"> |
| 2654 | 2654 | <label |
| 2655 | - for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label> |
|
| 2655 | + for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo esc_attr($args['title']); ?><?php echo $this->widget_field_desc($args); ?></label> |
|
| 2656 | 2656 | <?php |
| 2657 | 2657 | break; |
| 2658 | 2658 | case "textarea": |
| 2659 | 2659 | ?> |
| 2660 | 2660 | <label |
| 2661 | - for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label> |
|
| 2661 | + for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo esc_attr($args['title']); ?><?php echo $this->widget_field_desc($args); ?></label> |
|
| 2662 | 2662 | <textarea <?php echo $placeholder; ?> class="widefat" |
| 2663 | 2663 | <?php echo $custom_attributes; ?> |
| 2664 | - id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
|
| 2665 | - name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" |
|
| 2666 | - ><?php echo esc_attr( $value ); ?></textarea> |
|
| 2664 | + id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" |
|
| 2665 | + name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" |
|
| 2666 | + ><?php echo esc_attr($value); ?></textarea> |
|
| 2667 | 2667 | <?php |
| 2668 | 2668 | |
| 2669 | 2669 | break; |
| 2670 | 2670 | case "hidden": |
| 2671 | 2671 | ?> |
| 2672 | - <input id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" |
|
| 2673 | - name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="hidden" |
|
| 2674 | - value="<?php echo esc_attr( $value ); ?>"> |
|
| 2672 | + <input id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" |
|
| 2673 | + name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" type="hidden" |
|
| 2674 | + value="<?php echo esc_attr($value); ?>"> |
|
| 2675 | 2675 | <?php |
| 2676 | 2676 | break; |
| 2677 | 2677 | default: |
@@ -2693,14 +2693,14 @@ discard block |
||
| 2693 | 2693 | * @return string |
| 2694 | 2694 | * @todo, need to make its own tooltip script |
| 2695 | 2695 | */ |
| 2696 | - public function widget_field_desc( $args ) { |
|
| 2696 | + public function widget_field_desc($args) { |
|
| 2697 | 2697 | |
| 2698 | 2698 | $description = ''; |
| 2699 | - if ( isset( $args['desc'] ) && $args['desc'] ) { |
|
| 2700 | - if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) { |
|
| 2701 | - $description = $this->desc_tip( $args['desc'] ); |
|
| 2699 | + if (isset($args['desc']) && $args['desc']) { |
|
| 2700 | + if (isset($args['desc_tip']) && $args['desc_tip']) { |
|
| 2701 | + $description = $this->desc_tip($args['desc']); |
|
| 2702 | 2702 | } else { |
| 2703 | - $description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>'; |
|
| 2703 | + $description = '<span class="description">' . wp_kses_post($args['desc']) . '</span>'; |
|
| 2704 | 2704 | } |
| 2705 | 2705 | } |
| 2706 | 2706 | |
@@ -2715,11 +2715,11 @@ discard block |
||
| 2715 | 2715 | * |
| 2716 | 2716 | * @return string |
| 2717 | 2717 | */ |
| 2718 | - function desc_tip( $tip, $allow_html = false ) { |
|
| 2719 | - if ( $allow_html ) { |
|
| 2720 | - $tip = $this->sanitize_tooltip( $tip ); |
|
| 2718 | + function desc_tip($tip, $allow_html = false) { |
|
| 2719 | + if ($allow_html) { |
|
| 2720 | + $tip = $this->sanitize_tooltip($tip); |
|
| 2721 | 2721 | } else { |
| 2722 | - $tip = esc_attr( $tip ); |
|
| 2722 | + $tip = esc_attr($tip); |
|
| 2723 | 2723 | } |
| 2724 | 2724 | |
| 2725 | 2725 | return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
@@ -2732,8 +2732,8 @@ discard block |
||
| 2732 | 2732 | * |
| 2733 | 2733 | * @return string |
| 2734 | 2734 | */ |
| 2735 | - public function sanitize_tooltip( $var ) { |
|
| 2736 | - return htmlspecialchars( wp_kses( html_entity_decode( $var ), array( |
|
| 2735 | + public function sanitize_tooltip($var) { |
|
| 2736 | + return htmlspecialchars(wp_kses(html_entity_decode($var), array( |
|
| 2737 | 2737 | 'br' => array(), |
| 2738 | 2738 | 'em' => array(), |
| 2739 | 2739 | 'strong' => array(), |
@@ -2743,7 +2743,7 @@ discard block |
||
| 2743 | 2743 | 'li' => array(), |
| 2744 | 2744 | 'ol' => array(), |
| 2745 | 2745 | 'p' => array(), |
| 2746 | - ) ) ); |
|
| 2746 | + ))); |
|
| 2747 | 2747 | } |
| 2748 | 2748 | |
| 2749 | 2749 | /** |
@@ -2755,23 +2755,23 @@ discard block |
||
| 2755 | 2755 | * @return array |
| 2756 | 2756 | * @todo we should add some sanitation here. |
| 2757 | 2757 | */ |
| 2758 | - public function update( $new_instance, $old_instance ) { |
|
| 2758 | + public function update($new_instance, $old_instance) { |
|
| 2759 | 2759 | |
| 2760 | 2760 | //save the widget |
| 2761 | - $instance = array_merge( (array) $old_instance, (array) $new_instance ); |
|
| 2761 | + $instance = array_merge((array) $old_instance, (array) $new_instance); |
|
| 2762 | 2762 | |
| 2763 | 2763 | // set widget instance |
| 2764 | 2764 | $this->instance = $instance; |
| 2765 | 2765 | |
| 2766 | - if ( empty( $this->arguments ) ) { |
|
| 2766 | + if (empty($this->arguments)) { |
|
| 2767 | 2767 | $this->get_arguments(); |
| 2768 | 2768 | } |
| 2769 | 2769 | |
| 2770 | 2770 | // check for checkboxes |
| 2771 | - if ( ! empty( $this->arguments ) ) { |
|
| 2772 | - foreach ( $this->arguments as $argument ) { |
|
| 2773 | - if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) { |
|
| 2774 | - $instance[ $argument['name'] ] = '0'; |
|
| 2771 | + if (!empty($this->arguments)) { |
|
| 2772 | + foreach ($this->arguments as $argument) { |
|
| 2773 | + if (isset($argument['type']) && $argument['type'] == 'checkbox' && !isset($new_instance[$argument['name']])) { |
|
| 2774 | + $instance[$argument['name']] = '0'; |
|
| 2775 | 2775 | } |
| 2776 | 2776 | } |
| 2777 | 2777 | } |
@@ -2789,7 +2789,7 @@ discard block |
||
| 2789 | 2789 | */ |
| 2790 | 2790 | public function is_block_content_call() { |
| 2791 | 2791 | $result = false; |
| 2792 | - if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) { |
|
| 2792 | + if (wp_doing_ajax() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'super_duper_output_shortcode') { |
|
| 2793 | 2793 | $result = true; |
| 2794 | 2794 | } |
| 2795 | 2795 | |
@@ -660,7 +660,7 @@ discard block |
||
| 660 | 660 | <?php |
| 661 | 661 | if(! empty( $insert_shortcode_function )){ |
| 662 | 662 | echo $insert_shortcode_function; |
| 663 | - }else{ |
|
| 663 | + } else{ |
|
| 664 | 664 | |
| 665 | 665 | /** |
| 666 | 666 | * Function for super duper insert shortcode. |
@@ -1871,7 +1871,7 @@ discard block |
||
| 1871 | 1871 | $panel_count ++; |
| 1872 | 1872 | |
| 1873 | 1873 | } |
| 1874 | - }else { |
|
| 1874 | + } else { |
|
| 1875 | 1875 | ?> |
| 1876 | 1876 | el(wp.components.PanelBody, { |
| 1877 | 1877 | title: '<?php esc_attr_e( "Settings" ); ?>', |
@@ -1895,7 +1895,7 @@ discard block |
||
| 1895 | 1895 | // If the user sets block-output array then build it |
| 1896 | 1896 | if ( ! empty( $this->options['block-output'] ) ) { |
| 1897 | 1897 | $this->block_element( $this->options['block-output'] ); |
| 1898 | - }else{ |
|
| 1898 | + } else{ |
|
| 1899 | 1899 | // if no block-output is set then we try and get the shortcode html output via ajax. |
| 1900 | 1900 | ?> |
| 1901 | 1901 | el('div', { |
@@ -1965,7 +1965,7 @@ discard block |
||
| 1965 | 1965 | ?> |
| 1966 | 1966 | return content; |
| 1967 | 1967 | <?php |
| 1968 | - }else{ |
|
| 1968 | + } else{ |
|
| 1969 | 1969 | ?> |
| 1970 | 1970 | var block_wrap = 'div'; |
| 1971 | 1971 | if (attr.hasOwnProperty("block_wrap")) { |
@@ -3,102 +3,102 @@ discard block |
||
| 3 | 3 | class SD_Hello_World extends WP_Super_Duper { |
| 4 | 4 | |
| 5 | 5 | |
| 6 | - public $arguments; |
|
| 7 | - |
|
| 8 | - /** |
|
| 9 | - * Sets up the widgets name etc |
|
| 10 | - */ |
|
| 11 | - public function __construct() { |
|
| 12 | - |
|
| 13 | - $options = array( |
|
| 14 | - 'textdomain' => 'super-duper', |
|
| 15 | - // textdomain of the plugin/theme (used to prefix the Gutenberg block) |
|
| 16 | - 'block-icon' => 'fas fa-globe-americas', |
|
| 17 | - // Dash icon name for the block: https://developer.wordpress.org/resource/dashicons/#arrow-right |
|
| 18 | - // OR font-awesome 5 class name: fas fa-globe-americas |
|
| 19 | - 'block-category' => 'widgets', |
|
| 20 | - // the category for the block, 'common', 'formatting', 'layout', 'widgets', 'embed'. |
|
| 21 | - 'block-keywords' => "['hello','world']", |
|
| 22 | - // used in the block search, MAX 3 |
|
| 23 | - 'block-output' => array( // the block visual output elements as an array |
|
| 24 | - array( |
|
| 25 | - 'element' => 'p', |
|
| 26 | - 'title' => __( 'Placeholder', 'hello-world' ), |
|
| 27 | - 'class' => '[%className%]', |
|
| 28 | - 'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%] |
|
| 29 | - ) |
|
| 30 | - ), |
|
| 31 | - 'block-wrap' => '', // You can specify the type of element to wrap the block `div` or `span` etc.. Or blank for no wrap at all. |
|
| 32 | - 'class_name' => __CLASS__, |
|
| 33 | - // The calling class name |
|
| 34 | - 'base_id' => 'hello_world', |
|
| 35 | - // this is used as the widget id and the shortcode id. |
|
| 36 | - 'name' => __( 'Hello World', 'hello-world' ), |
|
| 37 | - // the name of the widget/block |
|
| 38 | - 'widget_ops' => array( |
|
| 39 | - 'classname' => 'hello-world-class', |
|
| 40 | - // widget class |
|
| 41 | - 'description' => esc_html__( 'This is an example that will take a text parameter and output it after `Hello:`.', 'hello-world' ), |
|
| 42 | - // widget description |
|
| 43 | - ), |
|
| 44 | - 'no_wrap' => true, // This will prevent the widget being wrapped in the containing widget class div. |
|
| 45 | - 'arguments' => array( // these are the arguments that will be used in the widget, shortcode and block settings. |
|
| 46 | - 'after_text' => array( // this is the input name='' |
|
| 47 | - 'title' => __( 'Text after hello:', 'hello-world' ), |
|
| 48 | - // input title |
|
| 49 | - 'desc' => __( 'This is the text that will appear after `Hello:`.', 'hello-world' ), |
|
| 50 | - // input description |
|
| 51 | - 'type' => 'text', |
|
| 52 | - // the type of input, test, select, checkbox etc. |
|
| 53 | - 'placeholder' => 'World', |
|
| 54 | - // the input placeholder text. |
|
| 55 | - 'desc_tip' => true, |
|
| 56 | - // if the input should show the widget description text as a tooltip. |
|
| 57 | - 'default' => 'World', |
|
| 58 | - // the input default value. |
|
| 59 | - 'advanced' => false |
|
| 60 | - // not yet implemented |
|
| 61 | - ), |
|
| 62 | - ) |
|
| 63 | - ); |
|
| 64 | - |
|
| 65 | - parent::__construct( $options ); |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * This is the output function for the widget, shortcode and block (front end). |
|
| 71 | - * |
|
| 72 | - * @param array $args The arguments values. |
|
| 73 | - * @param array $widget_args The widget arguments when used. |
|
| 74 | - * @param string $content The shortcode content argument |
|
| 75 | - * |
|
| 76 | - * @return string |
|
| 77 | - */ |
|
| 78 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * @var string $after_text |
|
| 82 | - * @var string $another_input This is added by filter below. |
|
| 83 | - */ |
|
| 84 | - extract( $args, EXTR_SKIP ); |
|
| 85 | - |
|
| 86 | - /* |
|
| 6 | + public $arguments; |
|
| 7 | + |
|
| 8 | + /** |
|
| 9 | + * Sets up the widgets name etc |
|
| 10 | + */ |
|
| 11 | + public function __construct() { |
|
| 12 | + |
|
| 13 | + $options = array( |
|
| 14 | + 'textdomain' => 'super-duper', |
|
| 15 | + // textdomain of the plugin/theme (used to prefix the Gutenberg block) |
|
| 16 | + 'block-icon' => 'fas fa-globe-americas', |
|
| 17 | + // Dash icon name for the block: https://developer.wordpress.org/resource/dashicons/#arrow-right |
|
| 18 | + // OR font-awesome 5 class name: fas fa-globe-americas |
|
| 19 | + 'block-category' => 'widgets', |
|
| 20 | + // the category for the block, 'common', 'formatting', 'layout', 'widgets', 'embed'. |
|
| 21 | + 'block-keywords' => "['hello','world']", |
|
| 22 | + // used in the block search, MAX 3 |
|
| 23 | + 'block-output' => array( // the block visual output elements as an array |
|
| 24 | + array( |
|
| 25 | + 'element' => 'p', |
|
| 26 | + 'title' => __( 'Placeholder', 'hello-world' ), |
|
| 27 | + 'class' => '[%className%]', |
|
| 28 | + 'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%] |
|
| 29 | + ) |
|
| 30 | + ), |
|
| 31 | + 'block-wrap' => '', // You can specify the type of element to wrap the block `div` or `span` etc.. Or blank for no wrap at all. |
|
| 32 | + 'class_name' => __CLASS__, |
|
| 33 | + // The calling class name |
|
| 34 | + 'base_id' => 'hello_world', |
|
| 35 | + // this is used as the widget id and the shortcode id. |
|
| 36 | + 'name' => __( 'Hello World', 'hello-world' ), |
|
| 37 | + // the name of the widget/block |
|
| 38 | + 'widget_ops' => array( |
|
| 39 | + 'classname' => 'hello-world-class', |
|
| 40 | + // widget class |
|
| 41 | + 'description' => esc_html__( 'This is an example that will take a text parameter and output it after `Hello:`.', 'hello-world' ), |
|
| 42 | + // widget description |
|
| 43 | + ), |
|
| 44 | + 'no_wrap' => true, // This will prevent the widget being wrapped in the containing widget class div. |
|
| 45 | + 'arguments' => array( // these are the arguments that will be used in the widget, shortcode and block settings. |
|
| 46 | + 'after_text' => array( // this is the input name='' |
|
| 47 | + 'title' => __( 'Text after hello:', 'hello-world' ), |
|
| 48 | + // input title |
|
| 49 | + 'desc' => __( 'This is the text that will appear after `Hello:`.', 'hello-world' ), |
|
| 50 | + // input description |
|
| 51 | + 'type' => 'text', |
|
| 52 | + // the type of input, test, select, checkbox etc. |
|
| 53 | + 'placeholder' => 'World', |
|
| 54 | + // the input placeholder text. |
|
| 55 | + 'desc_tip' => true, |
|
| 56 | + // if the input should show the widget description text as a tooltip. |
|
| 57 | + 'default' => 'World', |
|
| 58 | + // the input default value. |
|
| 59 | + 'advanced' => false |
|
| 60 | + // not yet implemented |
|
| 61 | + ), |
|
| 62 | + ) |
|
| 63 | + ); |
|
| 64 | + |
|
| 65 | + parent::__construct( $options ); |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * This is the output function for the widget, shortcode and block (front end). |
|
| 71 | + * |
|
| 72 | + * @param array $args The arguments values. |
|
| 73 | + * @param array $widget_args The widget arguments when used. |
|
| 74 | + * @param string $content The shortcode content argument |
|
| 75 | + * |
|
| 76 | + * @return string |
|
| 77 | + */ |
|
| 78 | + public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * @var string $after_text |
|
| 82 | + * @var string $another_input This is added by filter below. |
|
| 83 | + */ |
|
| 84 | + extract( $args, EXTR_SKIP ); |
|
| 85 | + |
|
| 86 | + /* |
|
| 87 | 87 | * This value is added by filter so might not exist if filter is removed so we check. |
| 88 | 88 | */ |
| 89 | - if ( ! isset( $another_input ) ) { |
|
| 90 | - $another_input = ''; |
|
| 91 | - } |
|
| 89 | + if ( ! isset( $another_input ) ) { |
|
| 90 | + $another_input = ''; |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - return "Hello: " . $after_text . "" . $another_input; |
|
| 93 | + return "Hello: " . $after_text . "" . $another_input; |
|
| 94 | 94 | |
| 95 | - } |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | // register it. |
| 100 | 100 | add_action( 'widgets_init', function () { |
| 101 | - register_widget( 'SD_Hello_World' ); |
|
| 101 | + register_widget( 'SD_Hello_World' ); |
|
| 102 | 102 | } ); |
| 103 | 103 | |
| 104 | 104 | |
@@ -111,26 +111,26 @@ discard block |
||
| 111 | 111 | */ |
| 112 | 112 | function _my_extra_arguments( $options ) { |
| 113 | 113 | |
| 114 | - /* |
|
| 114 | + /* |
|
| 115 | 115 | * Add a new input option. |
| 116 | 116 | */ |
| 117 | - $options['arguments']['another_input'] = array( |
|
| 118 | - 'name' => 'another_input', // this is the input name='' |
|
| 119 | - 'title' => __( 'Another input:', 'hello-world' ), // input title |
|
| 120 | - 'desc' => __( 'This is an input added via filter.', 'hello-world' ), // input description |
|
| 121 | - 'type' => 'text', // the type of input, test, select, checkbox etc. |
|
| 122 | - 'placeholder' => 'Placeholder text', // the input placeholder text. |
|
| 123 | - 'desc_tip' => true, // if the input should show the widget description text as a tooltip. |
|
| 124 | - 'default' => '', // the input default value. |
|
| 125 | - 'advanced' => false // not yet implemented |
|
| 126 | - ); |
|
| 127 | - |
|
| 128 | - /* |
|
| 117 | + $options['arguments']['another_input'] = array( |
|
| 118 | + 'name' => 'another_input', // this is the input name='' |
|
| 119 | + 'title' => __( 'Another input:', 'hello-world' ), // input title |
|
| 120 | + 'desc' => __( 'This is an input added via filter.', 'hello-world' ), // input description |
|
| 121 | + 'type' => 'text', // the type of input, test, select, checkbox etc. |
|
| 122 | + 'placeholder' => 'Placeholder text', // the input placeholder text. |
|
| 123 | + 'desc_tip' => true, // if the input should show the widget description text as a tooltip. |
|
| 124 | + 'default' => '', // the input default value. |
|
| 125 | + 'advanced' => false // not yet implemented |
|
| 126 | + ); |
|
| 127 | + |
|
| 128 | + /* |
|
| 129 | 129 | * Output the new option in the block output also. |
| 130 | 130 | */ |
| 131 | - $options['block-output']['element::p']['content'] = $options['block-output']['element::p']['content'] . " [%another_input%]";; |
|
| 131 | + $options['block-output']['element::p']['content'] = $options['block-output']['element::p']['content'] . " [%another_input%]";; |
|
| 132 | 132 | |
| 133 | - return $options; |
|
| 133 | + return $options; |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | //add_filter( 'wp_super_duper_options_hello_world', '_my_extra_arguments' ); |
| 137 | 137 | \ No newline at end of file |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | 'block-output' => array( // the block visual output elements as an array |
| 24 | 24 | array( |
| 25 | 25 | 'element' => 'p', |
| 26 | - 'title' => __( 'Placeholder', 'hello-world' ), |
|
| 26 | + 'title' => __('Placeholder', 'hello-world'), |
|
| 27 | 27 | 'class' => '[%className%]', |
| 28 | 28 | 'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%] |
| 29 | 29 | ) |
@@ -33,20 +33,20 @@ discard block |
||
| 33 | 33 | // The calling class name |
| 34 | 34 | 'base_id' => 'hello_world', |
| 35 | 35 | // this is used as the widget id and the shortcode id. |
| 36 | - 'name' => __( 'Hello World', 'hello-world' ), |
|
| 36 | + 'name' => __('Hello World', 'hello-world'), |
|
| 37 | 37 | // the name of the widget/block |
| 38 | 38 | 'widget_ops' => array( |
| 39 | 39 | 'classname' => 'hello-world-class', |
| 40 | 40 | // widget class |
| 41 | - 'description' => esc_html__( 'This is an example that will take a text parameter and output it after `Hello:`.', 'hello-world' ), |
|
| 41 | + 'description' => esc_html__('This is an example that will take a text parameter and output it after `Hello:`.', 'hello-world'), |
|
| 42 | 42 | // widget description |
| 43 | 43 | ), |
| 44 | 44 | 'no_wrap' => true, // This will prevent the widget being wrapped in the containing widget class div. |
| 45 | 45 | 'arguments' => array( // these are the arguments that will be used in the widget, shortcode and block settings. |
| 46 | 46 | 'after_text' => array( // this is the input name='' |
| 47 | - 'title' => __( 'Text after hello:', 'hello-world' ), |
|
| 47 | + 'title' => __('Text after hello:', 'hello-world'), |
|
| 48 | 48 | // input title |
| 49 | - 'desc' => __( 'This is the text that will appear after `Hello:`.', 'hello-world' ), |
|
| 49 | + 'desc' => __('This is the text that will appear after `Hello:`.', 'hello-world'), |
|
| 50 | 50 | // input description |
| 51 | 51 | 'type' => 'text', |
| 52 | 52 | // the type of input, test, select, checkbox etc. |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | ) |
| 63 | 63 | ); |
| 64 | 64 | |
| 65 | - parent::__construct( $options ); |
|
| 65 | + parent::__construct($options); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | |
@@ -75,18 +75,18 @@ discard block |
||
| 75 | 75 | * |
| 76 | 76 | * @return string |
| 77 | 77 | */ |
| 78 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 78 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | 81 | * @var string $after_text |
| 82 | 82 | * @var string $another_input This is added by filter below. |
| 83 | 83 | */ |
| 84 | - extract( $args, EXTR_SKIP ); |
|
| 84 | + extract($args, EXTR_SKIP); |
|
| 85 | 85 | |
| 86 | 86 | /* |
| 87 | 87 | * This value is added by filter so might not exist if filter is removed so we check. |
| 88 | 88 | */ |
| 89 | - if ( ! isset( $another_input ) ) { |
|
| 89 | + if (!isset($another_input)) { |
|
| 90 | 90 | $another_input = ''; |
| 91 | 91 | } |
| 92 | 92 | |
@@ -97,8 +97,8 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | // register it. |
| 100 | -add_action( 'widgets_init', function () { |
|
| 101 | - register_widget( 'SD_Hello_World' ); |
|
| 100 | +add_action('widgets_init', function() { |
|
| 101 | + register_widget('SD_Hello_World'); |
|
| 102 | 102 | } ); |
| 103 | 103 | |
| 104 | 104 | |
@@ -109,15 +109,15 @@ discard block |
||
| 109 | 109 | * |
| 110 | 110 | * @return mixed |
| 111 | 111 | */ |
| 112 | -function _my_extra_arguments( $options ) { |
|
| 112 | +function _my_extra_arguments($options) { |
|
| 113 | 113 | |
| 114 | 114 | /* |
| 115 | 115 | * Add a new input option. |
| 116 | 116 | */ |
| 117 | 117 | $options['arguments']['another_input'] = array( |
| 118 | 118 | 'name' => 'another_input', // this is the input name='' |
| 119 | - 'title' => __( 'Another input:', 'hello-world' ), // input title |
|
| 120 | - 'desc' => __( 'This is an input added via filter.', 'hello-world' ), // input description |
|
| 119 | + 'title' => __('Another input:', 'hello-world'), // input title |
|
| 120 | + 'desc' => __('This is an input added via filter.', 'hello-world'), // input description |
|
| 121 | 121 | 'type' => 'text', // the type of input, test, select, checkbox etc. |
| 122 | 122 | 'placeholder' => 'Placeholder text', // the input placeholder text. |
| 123 | 123 | 'desc_tip' => true, // if the input should show the widget description text as a tooltip. |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | /* |
| 129 | 129 | * Output the new option in the block output also. |
| 130 | 130 | */ |
| 131 | - $options['block-output']['element::p']['content'] = $options['block-output']['element::p']['content'] . " [%another_input%]";; |
|
| 131 | + $options['block-output']['element::p']['content'] = $options['block-output']['element::p']['content'] . " [%another_input%]"; ; |
|
| 132 | 132 | |
| 133 | 133 | return $options; |
| 134 | 134 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | public function getLocations() |
| 36 | 36 | { |
| 37 | 37 | if ($this->matchesCakeVersion('>=', '3.0.0')) { |
| 38 | - $this->locations['plugin'] = $this->composer->getConfig()->get('vendor-dir') . '/{$vendor}/{$name}/'; |
|
| 38 | + $this->locations['plugin'] = $this->composer->getConfig()->get('vendor-dir') . '/{$vendor}/{$name}/'; |
|
| 39 | 39 | } |
| 40 | 40 | return $this->locations; |
| 41 | 41 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | $repositoryManager = $this->composer->getRepositoryManager(); |
| 61 | - if (! $repositoryManager) { |
|
| 61 | + if (!$repositoryManager) { |
|
| 62 | 62 | return false; |
| 63 | 63 | } |
| 64 | 64 | |