| 1 |
<?php |
| 2 |
|
| 3 |
namespace YayMail\MailBuilder; |
| 4 |
|
| 5 |
use YayMail\Helper\Helper; |
| 6 |
|
| 7 |
defined( 'ABSPATH' ) || exit; |
| 8 |
/** |
| 9 |
* Settings Page |
| 10 |
*/ |
| 11 |
class YaymailElement { |
| 12 |
protected static $instance = null; |
| 13 |
public static function getInstance() { |
| 14 |
if ( null == self::$instance ) { |
| 15 |
self::$instance = new self(); |
| 16 |
self::$instance->doHooks(); |
| 17 |
} |
| 18 |
|
| 19 |
return self::$instance; |
| 20 |
} |
| 21 |
|
| 22 |
private function doHooks() { |
| 23 |
// BASIC |
| 24 |
add_action( 'YaymailLogo', array( $this, 'yaymail_logo' ), 100, 6 ); |
| 25 |
add_action( 'YaymailImages', array( $this, 'yaymail_images' ), 100, 6 ); |
| 26 |
add_action( 'YaymailElementText', array( $this, 'yaymail_element_text' ), 100, 6 ); |
| 27 |
add_action( 'YaymailButton', array( $this, 'yaymail_button' ), 100, 6 ); |
| 28 |
add_action( 'YaymailTitle', array( $this, 'yaymail_title' ), 100, 6 ); |
| 29 |
add_action( 'YaymailSocialIcon', array( $this, 'yaymail_social_icon' ), 100, 6 ); |
| 30 |
add_action( 'YaymailVideo', array( $this, 'yaymail_video' ), 100, 6 ); |
| 31 |
add_action( 'YaymailHTMLCode', array( $this, 'yaymail_html_code' ), 100, 6 ); |
| 32 |
add_action( 'YaymailImageList', array( $this, 'yaymail_image_list' ), 100, 6 ); |
| 33 |
add_action( 'YaymailImageBox', array( $this, 'yaymail_image_box' ), 100, 6 ); |
| 34 |
add_action( 'YaymailTextList', array( $this, 'yaymail_text_list' ), 100, 6 ); |
| 35 |
// GENERAL |
| 36 |
add_action( 'YaymailSpace', array( $this, 'yaymail_space' ), 100, 6 ); |
| 37 |
add_action( 'YaymailDivider', array( $this, 'yaymail_divider' ), 100, 6 ); |
| 38 |
add_action( 'YaymailOneColumn', array( $this, 'yaymail_one_column' ), 100, 6 ); |
| 39 |
add_action( 'YaymailTwoColumns', array( $this, 'yaymail_two_column' ), 100, 6 ); |
| 40 |
add_action( 'YaymailThreeColumns', array( $this, 'yaymail_three_column' ), 100, 6 ); |
| 41 |
add_action( 'YaymailFourColumns', array( $this, 'yaymail_four_column' ), 100, 6 ); |
| 42 |
// WOOCOMMERCE |
| 43 |
add_action( 'YaymailShippingAddress', array( $this, 'yaymail_shipping_address' ), 100, 6 ); |
| 44 |
add_action( 'YaymailBillingAddress', array( $this, 'yaymail_billing_address' ), 100, 6 ); |
| 45 |
add_action( 'YaymailOrderItem', array( $this, 'yaymail_order_item' ), 100, 6 ); |
| 46 |
add_action( 'YaymailOrderItemDownload', array( $this, 'yaymail_order_item_download' ), 100, 6 ); |
| 47 |
add_action( 'YaymailHook', array( $this, 'yaymail_hook' ), 100, 6 ); |
| 48 |
|
| 49 |
} |
| 50 |
|
| 51 |
public function yaymail_logo( $args, $attrs, $general_attrs, $id, $postID = '', $isInColumns = false ) { |
| 52 |
ob_start(); |
| 53 |
include YAYMAIL_PLUGIN_PATH . 'includes/Templates/Elements/YayMail/Logo.php'; |
| 54 |
$html = ob_get_contents(); |
| 55 |
ob_end_clean(); |
| 56 |
$html = do_shortcode( $html ); |
| 57 |
// Replace shortcode cannot do_shortcode |
| 58 |
$reg = '/\[yaymail.*?\]/m'; |
| 59 |
$html = preg_replace( $reg, '', $html ); |
| 60 |
echo wp_kses_post( $html ); |
| 61 |
} |
| 62 |
|
| 63 |
public function yaymail_images( $args, $attrs, $general_attrs, $id, $postID = '', $isInColumns = false ) { |
| 64 |
ob_start(); |
| 65 |
include YAYMAIL_PLUGIN_PATH . 'includes/Templates/Elements/YayMail/Images.php'; |
| 66 |
$html = ob_get_contents(); |
| 67 |
ob_end_clean(); |
| 68 |
$html = do_shortcode( $html ); |
| 69 |
// Replace shortcode cannot do_shortcode |
| 70 |
$reg = '/\[yaymail.*?\]/m'; |
| 71 |
$html = preg_replace( $reg, '', $html ); |
| 72 |
echo wp_kses_post( $html ); |
| 73 |
} |
| 74 |
|
| 75 |
public function yaymail_element_text( $args, $attrs, $general_attrs, $id, $postID = '', $isInColumns = false ) { |
| 76 |
ob_start(); |
| 77 |
include YAYMAIL_PLUGIN_PATH . 'includes/Templates/Elements/YayMail/ElementText.php'; |
| 78 |
$html = ob_get_contents(); |
| 79 |
ob_end_clean(); |
| 80 |
$html = do_shortcode( $html ); |
| 81 |
// Replace shortcode cannot do_shortcode |
| 82 |
$reg = '/\[yaymail.*?\]/m'; |
| 83 |
$html = preg_replace( $reg, '', $html ); |
| 84 |
$allowed_html_tags = wp_kses_allowed_html( 'post' ); |
| 85 |
$allowed_html_tags['style'] = array(); |
| 86 |
echo wp_kses( $html, $allowed_html_tags ); |
| 87 |
} |
| 88 |
|
| 89 |
public function yaymail_button( $args, $attrs, $general_attrs, $id, $postID = '', $isInColumns = false ) { |
| 90 |
ob_start(); |
| 91 |
include YAYMAIL_PLUGIN_PATH . 'includes/Templates/Elements/YayMail/Button.php'; |
| 92 |
$html = ob_get_contents(); |
| 93 |
ob_end_clean(); |
| 94 |
$html = do_shortcode( $html ); |
| 95 |
// Replace shortcode cannot do_shortcode |
| 96 |
$reg = '/\[yaymail.*?\]/m'; |
| 97 |
$html = preg_replace( $reg, '', $html ); |
| 98 |
echo wp_kses_post( $html ); |
| 99 |
} |
| 100 |
public function yaymail_title( $args, $attrs, $general_attrs, $id, $postID = '', $isInColumns = false ) { |
| 101 |
ob_start(); |
| 102 |
include YAYMAIL_PLUGIN_PATH . 'includes/Templates/Elements/YayMail/Title.php'; |
| 103 |
$html = ob_get_contents(); |
| 104 |
ob_end_clean(); |
| 105 |
$html = do_shortcode( $html ); |
| 106 |
// Replace shortcode cannot do_shortcode |
| 107 |
$reg = '/\[yaymail.*?\]/m'; |
| 108 |
$html = preg_replace( $reg, '', $html ); |
| 109 |
echo wp_kses_post( $html ); |
| 110 |
} |
| 111 |
|
| 112 |
public function yaymail_social_icon( $args, $attrs, $general_attrs, $id, $postID = '', $isInColumns = false ) { |
| 113 |
ob_start(); |
| 114 |
include YAYMAIL_PLUGIN_PATH . 'includes/Templates/Elements/YayMail/SocialIcon.php'; |
| 115 |
$html = ob_get_contents(); |
| 116 |
ob_end_clean(); |
| 117 |
$html = do_shortcode( $html ); |
| 118 |
// Replace shortcode cannot do_shortcode |
| 119 |
$reg = '/\[yaymail.*?\]/m'; |
| 120 |
$html = preg_replace( $reg, '', $html ); |
| 121 |
echo wp_kses_post( $html ); |
| 122 |
} |
| 123 |
|
| 124 |
public function yaymail_video( $args, $attrs, $general_attrs, $id, $postID = '', $isInColumns = false ) { |
| 125 |
ob_start(); |
| 126 |
include YAYMAIL_PLUGIN_PATH . 'includes/Templates/Elements/YayMail/Video.php'; |
| 127 |
$html = ob_get_contents(); |
| 128 |
ob_end_clean(); |
| 129 |
$html = do_shortcode( $html ); |
| 130 |
// Replace shortcode cannot do_shortcode |
| 131 |
$reg = '/\[yaymail.*?\]/m'; |
| 132 |
$html = preg_replace( $reg, '', $html ); |
| 133 |
echo wp_kses_post( $html ); |
| 134 |
} |
| 135 |
|
| 136 |
public function yaymail_shipping_address( $args, $attrs, $general_attrs, $id, $postID = '', $isInColumns = false ) { |
| 137 |
if ( ( isset( $args['order'] ) && 'SampleOrder' == $args['order'] ) || ( isset( $args['order'] ) && ! empty( $args['order'] ) && ! empty( $args['order']->get_formatted_shipping_address() ) ) ) { |
| 138 |
ob_start(); |
| 139 |
include YAYMAIL_PLUGIN_PATH . 'includes/Templates/Elements/YayMail/ShippingAddress.php'; |
| 140 |
$html = ob_get_contents(); |
| 141 |
ob_end_clean(); |
| 142 |
$html = do_shortcode( $html ); |
| 143 |
// Replace shortcode cannot do_shortcode |
| 144 |
$reg = '/\[yaymail.*?\]/m'; |
| 145 |
$html = preg_replace( $reg, '', $html ); |
| 146 |
echo wp_kses_post( $html ); |
| 147 |
} |
| 148 |
} |
| 149 |
|
| 150 |
public function yaymail_billing_address( $args, $attrs, $general_attrs, $id, $postID = '', $isInColumns = false ) { |
| 151 |
if ( ( isset( $args['order'] ) && 'SampleOrder' == $args['order'] ) || ( isset( $args['order'] ) && ! empty( $args['order'] ) && ! empty( $args['order']->get_formatted_billing_address() ) ) ) { |
| 152 |
ob_start(); |
| 153 |
include YAYMAIL_PLUGIN_PATH . 'includes/Templates/Elements/YayMail/BillingAddress.php'; |
| 154 |
$html = ob_get_contents(); |
| 155 |
ob_end_clean(); |
| 156 |
$html = do_shortcode( $html ); |
| 157 |
// Replace shortcode cannot do_shortcode |
| 158 |
$reg = '/\[yaymail.*?\]/m'; |
| 159 |
$html = preg_replace( $reg, '', $html ); |
| 160 |
echo wp_kses_post( $html ); |
| 161 |
} |
| 162 |
} |
| 163 |
|
| 164 |
public function yaymail_order_item( $args, $attrs, $general_attrs, $id, $postID = '', $isInColumns = false ) { |
| 165 |
ob_start(); |
| 166 |
include YAYMAIL_PLUGIN_PATH . 'includes/Templates/Elements/YayMail/OrderItem.php'; |
| 167 |
$html = ob_get_contents(); |
| 168 |
ob_end_clean(); |
| 169 |
$html = do_shortcode( $html ); |
| 170 |
// Replace shortcode cannot do_shortcode |
| 171 |
$reg = '/\[yaymail.*?\]/m'; |
| 172 |
$html = preg_replace( $reg, '', $html ); |
| 173 |
$allowed_html_tags = wp_kses_allowed_html( 'post' ); |
| 174 |
$allowed_html_tags['style'] = array(); |
| 175 |
echo wp_kses( $html, $allowed_html_tags ); |
| 176 |
} |
| 177 |
|
| 178 |
public function yaymail_html_code( $args, $attrs, $general_attrs, $id, $postID = '', $isInColumns = false ) { |
| 179 |
ob_start(); |
| 180 |
include YAYMAIL_PLUGIN_PATH . 'includes/Templates/Elements/YayMail/HTML.php'; |
| 181 |
$html = ob_get_contents(); |
| 182 |
ob_end_clean(); |
| 183 |
$html = do_shortcode( $html ); |
| 184 |
// Replace shortcode cannot do_shortcode |
| 185 |
$reg = '/\[yaymail.*?\]/m'; |
| 186 |
$html = preg_replace( $reg, '', $html ); |
| 187 |
echo wp_kses_post( $html ); |
| 188 |
} |
| 189 |
|
| 190 |
public function yaymail_image_list( $args, $attrs, $general_attrs, $id, $postID = '', $isInColumns = false ) { |
| 191 |
ob_start(); |
| 192 |
include YAYMAIL_PLUGIN_PATH . 'includes/Templates/Elements/YayMail/ImageList.php'; |
| 193 |
$html = ob_get_contents(); |
| 194 |
ob_end_clean(); |
| 195 |
$html = do_shortcode( $html ); |
| 196 |
// Replace shortcode cannot do_shortcode |
| 197 |
$reg = '/\[yaymail.*?\]/m'; |
| 198 |
$html = preg_replace( $reg, '', $html ); |
| 199 |
echo wp_kses_post( $html ); |
| 200 |
} |
| 201 |
|
| 202 |
public function yaymail_image_box( $args, $attrs, $general_attrs, $id, $postID = '', $isInColumns = false ) { |
| 203 |
ob_start(); |
| 204 |
include YAYMAIL_PLUGIN_PATH . 'includes/Templates/Elements/YayMail/ImageBox.php'; |
| 205 |
$html = ob_get_contents(); |
| 206 |
ob_end_clean(); |
| 207 |
$html = do_shortcode( $html ); |
| 208 |
// Replace shortcode cannot do_shortcode |
| 209 |
$reg = '/\[yaymail.*?\]/m'; |
| 210 |
$html = preg_replace( $reg, '', $html ); |
| 211 |
echo wp_kses_post( $html ); |
| 212 |
} |
| 213 |
|
| 214 |
public function yaymail_text_list( $args, $attrs, $general_attrs, $id, $postID = '', $isInColumns = false ) { |
| 215 |
ob_start(); |
| 216 |
include YAYMAIL_PLUGIN_PATH . 'includes/Templates/Elements/YayMail/TextList.php'; |
| 217 |
$html = ob_get_contents(); |
| 218 |
ob_end_clean(); |
| 219 |
$html = do_shortcode( $html ); |
| 220 |
// Replace shortcode cannot do_shortcode |
| 221 |
$reg = '/\[yaymail.*?\]/m'; |
| 222 |
$html = preg_replace( $reg, '', $html ); |
| 223 |
echo wp_kses_post( $html ); |
| 224 |
} |
| 225 |
|
| 226 |
public function yaymail_order_item_download( $args, $attrs, $general_attrs, $id, $postID = '', $isInColumns = false ) { |
| 227 |
ob_start(); |
| 228 |
include YAYMAIL_PLUGIN_PATH . 'includes/Templates/Elements/YayMail/OrderItemDownload.php'; |
| 229 |
$html = ob_get_contents(); |
| 230 |
ob_end_clean(); |
| 231 |
$html = do_shortcode( $html ); |
| 232 |
// Replace shortcode cannot do_shortcode |
| 233 |
$reg = '/\[yaymail.*?\]/m'; |
| 234 |
$html = preg_replace( $reg, '', $html ); |
| 235 |
echo wp_kses_post( $html ); |
| 236 |
} |
| 237 |
|
| 238 |
public function yaymail_hook( $args, $attrs, $general_attrs, $id, $postID = '', $isInColumns = false ) { |
| 239 |
ob_start(); |
| 240 |
include YAYMAIL_PLUGIN_PATH . 'includes/Templates/Elements/YayMail/Hook.php'; |
| 241 |
$html = ob_get_contents(); |
| 242 |
ob_end_clean(); |
| 243 |
$html = do_shortcode( $html ); |
| 244 |
// Replace shortcode cannot do_shortcode |
| 245 |
$reg = '/\[yaymail.*?\]/m'; |
| 246 |
$html = preg_replace( $reg, '', $html ); |
| 247 |
$allowed_html_tags = wp_kses_allowed_html( 'post' ); |
| 248 |
$allowed_html_tags['style'] = array(); |
| 249 |
echo wp_kses( $html, $allowed_html_tags ); |
| 250 |
} |
| 251 |
|
| 252 |
public function yaymail_space( $args, $attrs, $general_attrs, $id, $postID = '', $isInColumns = false ) { |
| 253 |
ob_start(); |
| 254 |
include YAYMAIL_PLUGIN_PATH . 'includes/Templates/Elements/YayMail/Space.php'; |
| 255 |
$html = ob_get_contents(); |
| 256 |
ob_end_clean(); |
| 257 |
$html = do_shortcode( $html ); |
| 258 |
// Replace shortcode cannot do_shortcode |
| 259 |
$reg = '/\[yaymail.*?\]/m'; |
| 260 |
$html = preg_replace( $reg, '', $html ); |
| 261 |
echo wp_kses_post( $html ); |
| 262 |
} |
| 263 |
|
| 264 |
public function yaymail_divider( $args, $attrs, $general_attrs, $id, $postID = '', $isInColumns = false ) { |
| 265 |
ob_start(); |
| 266 |
include YAYMAIL_PLUGIN_PATH . 'includes/Templates/Elements/YayMail/Divider.php'; |
| 267 |
$html = ob_get_contents(); |
| 268 |
ob_end_clean(); |
| 269 |
$html = do_shortcode( $html ); |
| 270 |
// Replace shortcode cannot do_shortcode |
| 271 |
$reg = '/\[yaymail.*?\]/m'; |
| 272 |
$html = preg_replace( $reg, '', $html ); |
| 273 |
echo wp_kses_post( $html ); |
| 274 |
} |
| 275 |
|
| 276 |
public function yaymail_one_column( $args, $attrs, $general_attrs, $id, $postID = '', $isInColumns = false ) { |
| 277 |
ob_start(); |
| 278 |
include YAYMAIL_PLUGIN_PATH . 'includes/Templates/Elements/YayMail/OneColumn.php'; |
| 279 |
$html = ob_get_contents(); |
| 280 |
ob_end_clean(); |
| 281 |
$html = do_shortcode( $html ); |
| 282 |
// Replace shortcode cannot do_shortcode |
| 283 |
$reg = '/\[yaymail.*?\]/m'; |
| 284 |
$html = preg_replace( $reg, '', $html ); |
| 285 |
$allowed_html_tags = wp_kses_allowed_html( 'post' ); |
| 286 |
$allowed_html_tags['style'] = array(); |
| 287 |
$allowed_html_tags = Helper::customAllowedHTMLTags( array( 'background' => true ) ); |
| 288 |
echo wp_kses( $html, $allowed_html_tags ); |
| 289 |
} |
| 290 |
|
| 291 |
public function yaymail_two_column( $args, $attrs, $general_attrs, $id, $postID = '', $isInColumns = false ) { |
| 292 |
ob_start(); |
| 293 |
include YAYMAIL_PLUGIN_PATH . 'includes/Templates/Elements/YayMail/TwoColumn.php'; |
| 294 |
$html = ob_get_contents(); |
| 295 |
ob_end_clean(); |
| 296 |
$html = do_shortcode( $html ); |
| 297 |
// Replace shortcode cannot do_shortcode |
| 298 |
$reg = '/\[yaymail.*?\]/m'; |
| 299 |
$html = preg_replace( $reg, '', $html ); |
| 300 |
$allowed_html_tags = wp_kses_allowed_html( 'post' ); |
| 301 |
$allowed_html_tags['style'] = array(); |
| 302 |
$allowed_html_tags = Helper::customAllowedHTMLTags( array( 'background' => true ) ); |
| 303 |
echo wp_kses( $html, $allowed_html_tags ); |
| 304 |
} |
| 305 |
|
| 306 |
public function yaymail_three_column( $args, $attrs, $general_attrs, $id, $postID = '', $isInColumns = false ) { |
| 307 |
ob_start(); |
| 308 |
include YAYMAIL_PLUGIN_PATH . 'includes/Templates/Elements/YayMail/ThreeColumn.php'; |
| 309 |
$html = ob_get_contents(); |
| 310 |
ob_end_clean(); |
| 311 |
$html = do_shortcode( $html ); |
| 312 |
// Replace shortcode cannot do_shortcode |
| 313 |
$reg = '/\[yaymail.*?\]/m'; |
| 314 |
$html = preg_replace( $reg, '', $html ); |
| 315 |
$allowed_html_tags = wp_kses_allowed_html( 'post' ); |
| 316 |
$allowed_html_tags['style'] = array(); |
| 317 |
$allowed_html_tags = Helper::customAllowedHTMLTags( array( 'background' => true ) ); |
| 318 |
echo wp_kses( $html, $allowed_html_tags ); |
| 319 |
} |
| 320 |
|
| 321 |
public function yaymail_four_column( $args, $attrs, $general_attrs, $id, $postID = '', $isInColumns = false ) { |
| 322 |
ob_start(); |
| 323 |
include YAYMAIL_PLUGIN_PATH . 'includes/Templates/Elements/YayMail/FourColumn.php'; |
| 324 |
$html = ob_get_contents(); |
| 325 |
ob_end_clean(); |
| 326 |
$html = do_shortcode( $html ); |
| 327 |
// Replace shortcode cannot do_shortcode |
| 328 |
$reg = '/\[yaymail.*?\]/m'; |
| 329 |
$html = preg_replace( $reg, '', $html ); |
| 330 |
$allowed_html_tags = wp_kses_allowed_html( 'post' ); |
| 331 |
$allowed_html_tags['style'] = array(); |
| 332 |
$allowed_html_tags = Helper::customAllowedHTMLTags( array( 'background' => true ) ); |
| 333 |
echo wp_kses( $html, $allowed_html_tags ); |
| 334 |
} |
| 335 |
} |
| 336 |
|