| 1 |
<?php |
| 2 |
/** |
| 3 |
* The admin-specific functionality of the plugin. |
| 4 |
* |
| 5 |
* @link https://wpdeveloper.net |
| 6 |
* @since 1.0.0 |
| 7 |
* |
| 8 |
* @package NotificationX |
| 9 |
* @subpackage NotificationX/admin |
| 10 |
* @author WPDeveloper <support@wpdeveloper.net> |
| 11 |
*/ |
| 12 |
|
| 13 |
class NotificationX_Admin { |
| 14 |
|
| 15 |
/** |
| 16 |
* The ID of this plugin. |
| 17 |
* |
| 18 |
* @since 1.0.0 |
| 19 |
* @access private |
| 20 |
* @var string $plugin_name The ID of this plugin. |
| 21 |
*/ |
| 22 |
private $plugin_name; |
| 23 |
/** |
| 24 |
* All builder args |
| 25 |
* |
| 26 |
* @var array |
| 27 |
*/ |
| 28 |
private $builder_args; |
| 29 |
/** |
| 30 |
* Builder Metabox ID |
| 31 |
* |
| 32 |
* @var string |
| 33 |
*/ |
| 34 |
private $metabox_id; |
| 35 |
|
| 36 |
/** |
| 37 |
* The version of this plugin. |
| 38 |
* |
| 39 |
* @since 1.0.0 |
| 40 |
* @access private |
| 41 |
* @var string $version The current version of this plugin. |
| 42 |
*/ |
| 43 |
private $version; |
| 44 |
|
| 45 |
/** |
| 46 |
* The type. |
| 47 |
* |
| 48 |
* @since 1.0.0 |
| 49 |
* @access public |
| 50 |
* @var string the post type of notificationx. |
| 51 |
*/ |
| 52 |
public $type = 'notificationx'; |
| 53 |
|
| 54 |
public $metabox; |
| 55 |
|
| 56 |
public static $prefix = 'nx_meta_'; |
| 57 |
|
| 58 |
public static $settings; |
| 59 |
|
| 60 |
/** |
| 61 |
* Initialize the class and set its properties. |
| 62 |
* |
| 63 |
* @since 1.0.0 |
| 64 |
* @param string $plugin_name The name of this plugin. |
| 65 |
* @param string $version The version of this plugin. |
| 66 |
*/ |
| 67 |
public function __construct( $plugin_name, $version ) { |
| 68 |
|
| 69 |
$this->plugin_name = $plugin_name; |
| 70 |
$this->version = $version; |
| 71 |
self::$settings = NotificationX_DB::get_settings(); |
| 72 |
} |
| 73 |
/** |
| 74 |
* Get all active items. |
| 75 |
* |
| 76 |
* @return void |
| 77 |
*/ |
| 78 |
public static function get_active_items() { |
| 79 |
// WP Query arguments. |
| 80 |
$args = array( |
| 81 |
'post_type' => 'notificationx', |
| 82 |
'posts_per_page' => '-1', |
| 83 |
'post_status' => 'publish', |
| 84 |
); |
| 85 |
$active = []; |
| 86 |
// Get the notification posts. |
| 87 |
$posts = get_posts( $args ); |
| 88 |
|
| 89 |
if ( count( $posts ) ) { |
| 90 |
foreach ( $posts as $post ) { |
| 91 |
$settings = NotificationX_MetaBox::get_metabox_settings( $post->ID ); |
| 92 |
$type = ( $settings->display_type != 'conversions' ) ? $settings->display_type : $settings->conversion_from; |
| 93 |
|
| 94 |
$active[ $type ][] = $post->ID; |
| 95 |
} |
| 96 |
} |
| 97 |
|
| 98 |
return $active; |
| 99 |
} |
| 100 |
/** |
| 101 |
* Register the stylesheets for the admin area. |
| 102 |
* |
| 103 |
* @since 1.0.0 |
| 104 |
*/ |
| 105 |
public function enqueue_styles( $hook ) { |
| 106 |
global $post_type; |
| 107 |
$page_status = false; |
| 108 |
wp_enqueue_style( |
| 109 |
$this->plugin_name . '-admin-global', |
| 110 |
NOTIFICATIONX_ADMIN_URL . 'assets/css/nx-admin-global.min.css', |
| 111 |
array(), $this->version, 'all' |
| 112 |
); |
| 113 |
if( $hook == 'notificationx_page_nx-builder' || $hook == 'notificationx_page_nx-settings' ) { |
| 114 |
$page_status = true; |
| 115 |
} |
| 116 |
|
| 117 |
if( $post_type != $this->type && ! $page_status ) { |
| 118 |
return; |
| 119 |
} |
| 120 |
|
| 121 |
wp_enqueue_style( 'wp-color-picker' ); |
| 122 |
wp_enqueue_style( |
| 123 |
$this->plugin_name . '-select2', |
| 124 |
NOTIFICATIONX_ADMIN_URL . 'assets/css/select2.min.css', |
| 125 |
array(), $this->version, 'all' |
| 126 |
); |
| 127 |
wp_enqueue_style( |
| 128 |
$this->plugin_name, |
| 129 |
NOTIFICATIONX_ADMIN_URL . 'assets/css/nx-admin.min.css', |
| 130 |
array(), $this->version, 'all' |
| 131 |
); |
| 132 |
} |
| 133 |
/** |
| 134 |
* Register the JavaScript for the admin area. |
| 135 |
* |
| 136 |
* @since 1.0.0 |
| 137 |
*/ |
| 138 |
public function enqueue_scripts( $hook ) { |
| 139 |
global $post_type; |
| 140 |
$page_status = false; |
| 141 |
|
| 142 |
if( $hook == 'notificationx_page_nx-builder' || $hook == 'notificationx_page_nx-settings' ) { |
| 143 |
$page_status = true; |
| 144 |
} |
| 145 |
|
| 146 |
if( $post_type != $this->type && ! $page_status ) { |
| 147 |
return; |
| 148 |
} |
| 149 |
|
| 150 |
wp_enqueue_script( 'wp-color-picker' ); |
| 151 |
wp_enqueue_script( 'jquery-ui-datepicker' ); |
| 152 |
wp_enqueue_media(); |
| 153 |
wp_enqueue_script( |
| 154 |
$this->plugin_name . '-sweetalert', |
| 155 |
NOTIFICATIONX_ADMIN_URL . 'assets/js/sweetalert.min.js', |
| 156 |
array( 'jquery' ), $this->version, true |
| 157 |
); |
| 158 |
wp_enqueue_script( |
| 159 |
$this->plugin_name . '-select2', |
| 160 |
NOTIFICATIONX_ADMIN_URL . 'assets/js/select2.min.js', |
| 161 |
array( 'jquery' ), $this->version, true |
| 162 |
); |
| 163 |
wp_enqueue_script( |
| 164 |
$this->plugin_name, |
| 165 |
NOTIFICATIONX_ADMIN_URL . 'assets/js/nx-admin.js', |
| 166 |
array( 'jquery' ), $this->version, true |
| 167 |
); |
| 168 |
|
| 169 |
wp_localize_script( $this->plugin_name, 'notificationx', self::toggleFields() ); |
| 170 |
} |
| 171 |
|
| 172 |
public function toggleFields( $builder = false ){ |
| 173 |
$args = NotificationX_MetaBox::get_args(); |
| 174 |
if( $builder ) { |
| 175 |
$args = NotificationX_MetaBox::get_builder_args(); |
| 176 |
} |
| 177 |
|
| 178 |
$toggleFields = $hideFields = $conditions = array(); |
| 179 |
|
| 180 |
$tabs = $args[ 'tabs' ]; |
| 181 |
if( ! empty( $tabs ) ) { |
| 182 |
foreach( $tabs as $tab_id => $tab ) { |
| 183 |
$sections = isset( $tab['sections'] ) ? $tab[ 'sections' ] : []; |
| 184 |
if( ! empty( $sections ) ) { |
| 185 |
foreach( $sections as $section_id => $section ) { |
| 186 |
$fields = isset( $section['fields'] ) ? $section[ 'fields' ] : []; |
| 187 |
if( ! empty( $fields ) ) { |
| 188 |
foreach( $fields as $field_key => $field ) { |
| 189 |
if( isset( $field['hide'] ) && ! empty( $field['hide'] ) && is_array( $field['hide'] ) ) { |
| 190 |
foreach( $field['hide'] as $key => $hide ) { |
| 191 |
$hideFields[ $field_key ][ $key ] = $hide; |
| 192 |
} |
| 193 |
} |
| 194 |
if( isset( $field['dependency'] ) && ! empty( $field['dependency'] ) && is_array( $field['dependency'] ) ) { |
| 195 |
foreach( $field['dependency'] as $key => $dependency ) { |
| 196 |
$conditions[ $field_key ][ $key ] = $dependency; |
| 197 |
} |
| 198 |
} |
| 199 |
} |
| 200 |
} |
| 201 |
} |
| 202 |
} |
| 203 |
} |
| 204 |
} |
| 205 |
|
| 206 |
return array( 'toggleFields' => $conditions, 'hideFields' => $hideFields ); |
| 207 |
} |
| 208 |
|
| 209 |
public function custom_columns( $columns ) { |
| 210 |
$title_column = $columns['title']; |
| 211 |
$date_column = $columns['date']; |
| 212 |
|
| 213 |
unset( $columns['title'] ); |
| 214 |
unset( $columns['date'] ); |
| 215 |
|
| 216 |
$columns['notification_status'] = __('Enable / Disable', 'notificationx'); |
| 217 |
$columns['title'] = $title_column; |
| 218 |
|
| 219 |
$columns['notification_type'] = __('Type', 'notificationx'); |
| 220 |
|
| 221 |
$columns['date'] = $date_column; |
| 222 |
|
| 223 |
return apply_filters('nx_post_columns', $columns ); |
| 224 |
} |
| 225 |
|
| 226 |
public function manage_custom_columns( $column, $post_id ){ |
| 227 |
switch ( $column ) { |
| 228 |
case 'notification_type': |
| 229 |
$type = get_post_meta( $post_id, '_nx_meta_display_type', true ); |
| 230 |
if ( $type ) { |
| 231 |
$type = NotificationX_Helper::notification_types( $type ); |
| 232 |
if( $type !== 'Conversions' ) { |
| 233 |
echo $type; |
| 234 |
} else { |
| 235 |
$from = get_post_meta( $post_id, '_nx_meta_conversion_from', true ); |
| 236 |
echo $type . ' - ' . NotificationX_Helper::conversion_from( $from ); |
| 237 |
} |
| 238 |
} |
| 239 |
break; |
| 240 |
case 'notification_status': |
| 241 |
$status = get_post_meta( $post_id, '_nx_meta_active_check', true ); |
| 242 |
self::notification_toggle( $status, $post_id ); |
| 243 |
break; |
| 244 |
} |
| 245 |
|
| 246 |
do_action( 'nx_post_columns_content', $column, $post_id ); |
| 247 |
} |
| 248 |
|
| 249 |
public static function notification_toggle( $status = '1', $post_id ){ |
| 250 |
$text = __('Active', 'notificationx'); |
| 251 |
$img_active = NOTIFICATIONX_ADMIN_URL . 'assets/img/active1.png'; |
| 252 |
$img_inactive = NOTIFICATIONX_ADMIN_URL . 'assets/img/active0.png'; |
| 253 |
$active = 'true'; |
| 254 |
$img = $img_active; |
| 255 |
|
| 256 |
if ( ! $status ) { |
| 257 |
$text = __('Inactive', 'notificationx'); |
| 258 |
$img = $img_inactive; |
| 259 |
$active = 'false'; |
| 260 |
} |
| 261 |
?> |
| 262 |
<img |
| 263 |
src="<?php echo $img; ?>" |
| 264 |
style="cursor: pointer; height: 16px; vertical-align: middle;" |
| 265 |
alt="<?php echo $text; ?>" title="<?php echo $text; ?>" |
| 266 |
data-nonce="<?php echo wp_create_nonce('notificationx_status_nonce'); ?>" |
| 267 |
data-post="<?php echo $post_id; ?>" /> |
| 268 |
<?php |
| 269 |
} |
| 270 |
|
| 271 |
public function notification_status(){ |
| 272 |
$error = false; |
| 273 |
|
| 274 |
if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'notificationx_status_nonce' ) ) { |
| 275 |
$error = true; |
| 276 |
} |
| 277 |
|
| 278 |
if ( ! isset( $_POST['post_id'] ) || empty( $_POST['post_id'] ) || ! absint( $_POST['post_id'] ) ) { |
| 279 |
$error = true; |
| 280 |
} |
| 281 |
|
| 282 |
if ( $error ) { |
| 283 |
echo __('There is an error updating status.', 'notificationx'); |
| 284 |
die(); |
| 285 |
} |
| 286 |
|
| 287 |
$post_id = absint( $_POST['post_id'] ); |
| 288 |
$status = $_POST['status'] == 'active' ? '1' : '0'; |
| 289 |
|
| 290 |
update_post_meta( $post_id, '_nx_meta_active_check', $status ); |
| 291 |
|
| 292 |
echo 'success'; |
| 293 |
die(); |
| 294 |
} |
| 295 |
/** |
| 296 |
* Register the NotificationX custom post type. |
| 297 |
* |
| 298 |
* @since 1.0.0 |
| 299 |
*/ |
| 300 |
public function register(){ |
| 301 |
|
| 302 |
$labels = array( |
| 303 |
'name' => 'NotificationX', |
| 304 |
'singular_name' => 'NotificationX', |
| 305 |
'add_new' => esc_html__( 'Add New', 'notificationx' ) , |
| 306 |
'add_new_item' => esc_html__( 'Add New', 'notificationx' ), |
| 307 |
'edit_item' => esc_html__( 'Edit', 'notificationx' ), |
| 308 |
'new_item' => esc_html__( 'New', 'notificationx' ), |
| 309 |
'view_item' => esc_html__( 'View', 'notificationx' ), |
| 310 |
'search_items' => esc_html__( 'Search', 'notificationx' ), |
| 311 |
'not_found' => esc_html__( 'No notification x is found', 'notificationx' ), |
| 312 |
'not_found_in_trash' => esc_html__( 'No notification x is found in Trash', 'notificationx' ), |
| 313 |
'menu_name' => 'NotificationX', |
| 314 |
); |
| 315 |
|
| 316 |
$args = array( |
| 317 |
'labels' => $labels, |
| 318 |
'hierarchical' => false, |
| 319 |
'description' => '', |
| 320 |
'taxonomies' => array( '' ), |
| 321 |
'public' => false, |
| 322 |
'show_ui' => true, |
| 323 |
'show_in_menu' => 'notificationx', |
| 324 |
'show_in_admin_bar' => true, |
| 325 |
'show_in_rest' => false, |
| 326 |
'menu_position' => 80, |
| 327 |
'menu_icon' => NOTIFICATIONX_ADMIN_URL . 'assets/img/nx-menu-icon.png', |
| 328 |
'show_in_nav_menus' => false, |
| 329 |
'publicly_queryable' => false, |
| 330 |
'exclude_from_search' => true, |
| 331 |
'has_archive' => false, |
| 332 |
'query_var' => true, |
| 333 |
'can_export' => true, |
| 334 |
'rewrite' => '', |
| 335 |
'capability_type' => 'post', |
| 336 |
'supports' => array( 'title' ), |
| 337 |
); |
| 338 |
|
| 339 |
register_post_type( $this->type, $args ); |
| 340 |
add_image_size( "_nx_notification_thumb", 100, 100, true ); |
| 341 |
} |
| 342 |
|
| 343 |
/** |
| 344 |
* Admin Menu Page |
| 345 |
* |
| 346 |
* @return void |
| 347 |
*/ |
| 348 |
public function menu_page(){ |
| 349 |
|
| 350 |
if( ! current_user_can( 'manage_options' ) ) { |
| 351 |
return; |
| 352 |
} |
| 353 |
|
| 354 |
$settings_class = new NotificationX_Settings(); |
| 355 |
|
| 356 |
$settings = apply_filters( 'notificationx_admin_menu', array( |
| 357 |
'nx-settings' => array( |
| 358 |
'title' => __('Settings', 'notificationx'), |
| 359 |
'capability' => 'delete_users', |
| 360 |
'callback' => array( $settings_class, 'settings_page' ) |
| 361 |
), |
| 362 |
'nx-builder' => array( |
| 363 |
'title' => __('Quick Builder', 'notificationx'), |
| 364 |
'capability' => 'delete_users', |
| 365 |
'callback' => array( $this, 'quick_builder' ) |
| 366 |
), |
| 367 |
) ); |
| 368 |
|
| 369 |
$this->builder_args = NotificationX_MetaBox::get_builder_args(); |
| 370 |
$this->metabox_id = $this->builder_args['id']; |
| 371 |
$flag = true; |
| 372 |
/** |
| 373 |
* Add Submit |
| 374 |
*/ |
| 375 |
if( isset( $_POST[ 'nx_builder_add_submit' ] ) ) : |
| 376 |
if ( ! isset( $_POST[$this->metabox_id . '_nonce'] ) || ! wp_verify_nonce( $_POST[$this->metabox_id . '_nonce'], $this->metabox_id ) ) { |
| 377 |
$flag = false; |
| 378 |
} |
| 379 |
|
| 380 |
if( $flag ) { |
| 381 |
|
| 382 |
if( $_POST['nx_meta_display_type'] == 'press_bar' ) { |
| 383 |
$title = __('NotificationX - Notification Bar', 'notificationx'); |
| 384 |
} elseif( $_POST['nx_meta_display_type'] == 'comments' ) { |
| 385 |
$title = __('NotificationX - WP Comments', 'notificationx'); |
| 386 |
} elseif( $_POST['nx_meta_display_type'] == 'conversions' ) { |
| 387 |
$conversions = NotificationX_Helper::conversion_from(); |
| 388 |
$title = 'NotificationX - ' . $conversions[$_POST['nx_meta_conversion_from']]; |
| 389 |
} |
| 390 |
$_POST['post_type'] = 'notificationx'; |
| 391 |
$postdata = array( |
| 392 |
'post_type' => 'notificationx', |
| 393 |
'post_title' => $title . ' - ' . date( get_option( 'date_format' ), current_time( 'timestamp' ) ), |
| 394 |
'post_status' => 'publish', |
| 395 |
'post_author' => get_current_user_id() |
| 396 |
); |
| 397 |
|
| 398 |
$p_id = wp_insert_post($postdata); |
| 399 |
if( $p_id || ! is_wp_error( $p_id ) ) { |
| 400 |
do_action( 'nx_before_builder_submit', $_POST ); |
| 401 |
// saving builder meta data with post |
| 402 |
NotificationX_MetaBox::save_data( $this->builder_data( $_POST ), $p_id ); |
| 403 |
/** |
| 404 |
* Safely Redirect to NotificationX Page |
| 405 |
*/ |
| 406 |
wp_safe_redirect( add_query_arg( array( |
| 407 |
'post_type' => 'notificationx', |
| 408 |
), admin_url( 'edit.php' ) ) ); |
| 409 |
} |
| 410 |
} |
| 411 |
endif; |
| 412 |
add_menu_page( 'NotificationX', 'NotificationX', 'delete_users', 'notificationx', '', NOTIFICATIONX_ADMIN_URL . 'assets/img/nx-menu-icon.png', 80 ); |
| 413 |
foreach( $settings as $slug => $setting ) { |
| 414 |
$cap = isset( $setting['capability'] ) ? $setting['capability'] : 'delete_users'; |
| 415 |
$hook = add_submenu_page( 'notificationx', $setting['title'], $setting['title'], $cap, $slug, $setting['callback'] ); |
| 416 |
} |
| 417 |
} |
| 418 |
|
| 419 |
public function quick_builder(){ |
| 420 |
$builder_args = $this->builder_args; |
| 421 |
$tabs = $this->builder_args['tabs']; |
| 422 |
$prefix = self::$prefix; |
| 423 |
$metabox_id = $this->metabox_id; |
| 424 |
/** |
| 425 |
* This lines of code is for editing a notification in simple|quick builder |
| 426 |
* |
| 427 |
* @var [type] |
| 428 |
*/ |
| 429 |
$idd = null; |
| 430 |
if( isset( $_GET['post_id'] ) && ! empty( $_GET['post_id'] )) { |
| 431 |
$idd = intval( $_GET['post_id'] ); |
| 432 |
} |
| 433 |
include_once NOTIFICATIONX_ADMIN_DIR_PATH . 'partials/nx-quick-builder-display.php'; |
| 434 |
} |
| 435 |
/** |
| 436 |
* Generate the builder data acording to default meta data |
| 437 |
* |
| 438 |
* @param array $data |
| 439 |
* @return array |
| 440 |
*/ |
| 441 |
protected function builder_data( $data ) { |
| 442 |
$post_data = []; |
| 443 |
$prefix = self::$prefix; |
| 444 |
$meta_fields = NotificationX_MetaBox::get_metabox_fields( $prefix ); |
| 445 |
foreach( $meta_fields as $meta_key => $meta_field ) { |
| 446 |
if( in_array( $meta_key, array_keys($data) ) ) { |
| 447 |
$post_data[ $meta_key ] = $data[ $meta_key ]; |
| 448 |
} else { |
| 449 |
$post_data[ $meta_key ] = ''; |
| 450 |
|
| 451 |
if( isset( $meta_field['defaults'] ) ) { |
| 452 |
$post_data[ $meta_key ] = $meta_field['defaults']; |
| 453 |
} |
| 454 |
if( isset( $meta_field['default'] ) ) { |
| 455 |
$post_data[ $meta_key ] = $meta_field['default']; |
| 456 |
} |
| 457 |
} |
| 458 |
} |
| 459 |
|
| 460 |
return array_merge( $post_data, $data ); |
| 461 |
} |
| 462 |
|
| 463 |
public static function get_form_action( $query_var = '', $builder_form = false ) { |
| 464 |
$page = '/admin.php?page=nx-settings'; |
| 465 |
if( $builder_form ) { |
| 466 |
$page = '/admin.php?page=nx-builder'; |
| 467 |
} |
| 468 |
|
| 469 |
if ( is_network_admin() ) { |
| 470 |
return network_admin_url( $page . $query_var ); |
| 471 |
} else { |
| 472 |
return admin_url( $page . $query_var ); |
| 473 |
} |
| 474 |
} |
| 475 |
|
| 476 |
public function notification_preview(){ |
| 477 |
global $pagenow, $post_type, $post; |
| 478 |
if ( ! in_array( $pagenow, array( 'post.php', 'post-new.php' ) ) ) { |
| 479 |
return false; |
| 480 |
} |
| 481 |
if ( $this->type != $post_type ) { |
| 482 |
return false; |
| 483 |
} |
| 484 |
$display_type = get_post_meta( $post->ID, '_nx_meta_display_type', true ); |
| 485 |
|
| 486 |
include NOTIFICATIONX_ADMIN_DIR_PATH . 'partials/nx-admin-preview.php'; |
| 487 |
} |
| 488 |
|
| 489 |
public function preview_html( $settings, $type = 'conversion' ){ |
| 490 |
$data = array( |
| 491 |
'comment' => array( |
| 492 |
'link' => '#', |
| 493 |
'post_title' => 'Hello world!', |
| 494 |
'post_link' => '#', |
| 495 |
'timestamp' => '1550986787', |
| 496 |
'user_id' => get_current_user_id(), |
| 497 |
'name' => 'John D', |
| 498 |
), |
| 499 |
'conversion' => array( |
| 500 |
'link' => '#', |
| 501 |
'title' => 'Hello world!', |
| 502 |
'timestamp' => '1550986787', |
| 503 |
'user_id' => get_current_user_id(), |
| 504 |
'name' => 'John D', |
| 505 |
) |
| 506 |
); |
| 507 |
|
| 508 |
$unique_id = uniqid( 'notificationx-' ); |
| 509 |
$output = '<div id="'. esc_attr( $unique_id ) .'" class="nx-notification '. NotificationX_Extension::get_classes( $settings ) .'">'; |
| 510 |
$output .= '<div '. NotificationX_Public::generate_preview_css( $settings ) .' class="notificationx-inner '. NotificationX_Extension::get_classes( $settings, 'inner' ) .'">'; |
| 511 |
$output .= '<div class="notificationx-image nx-preview-image">'; |
| 512 |
$output .= '<img class="'. NotificationX_Extension::get_classes( $settings, 'img' ) .'" src="'. NOTIFICATIONX_ADMIN_URL . 'assets/img/placeholder-300x300.png" alt="">'; |
| 513 |
$output .= '</div>'; |
| 514 |
$output .= '<div class="notificationx-content">'; |
| 515 |
if( $type === 'conversion' ) : |
| 516 |
$output .= NotificationX_Template::get_template_ready( $settings->woo_template, NotificationX_Extension::newData( $data[ 'conversion' ] ), $settings ); |
| 517 |
endif; |
| 518 |
if( $type === 'comment' ) : |
| 519 |
$output .= NotificationX_Template::get_template_ready( $settings->comments_template, NotificationX_Extension::newData( $data[ 'comment' ] ), $settings ); |
| 520 |
endif; |
| 521 |
if( $settings->close_button ) : |
| 522 |
$output .= '<span class="notificationx-close nx-preview-close"><svg width="8px" height="8px" viewBox="0 0 48 48" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><g id="Page-1" stroke="none" stroke-width="1" fill-rule="evenodd"><g id="close" fill-rule="nonzero"><path d="M28.228,23.986 L47.092,5.122 C48.264,3.951 48.264,2.051 47.092,0.88 C45.92,-0.292 44.022,-0.292 42.85,0.88 L23.986,19.744 L5.121,0.88 C3.949,-0.292 2.051,-0.292 0.879,0.88 C-0.293,2.051 -0.293,3.951 0.879,5.122 L19.744,23.986 L0.879,42.85 C-0.293,44.021 -0.293,45.921 0.879,47.092 C1.465,47.677 2.233,47.97 3,47.97 C3.767,47.97 4.535,47.677 5.121,47.091 L23.986,28.227 L42.85,47.091 C43.436,47.677 44.204,47.97 44.971,47.97 C45.738,47.97 46.506,47.677 47.092,47.091 C48.264,45.92 48.264,44.02 47.092,42.849 L28.228,23.986 Z" id="Shape"></path></g></g></svg></span>'; |
| 523 |
endif; |
| 524 |
if( is_null( NotificationX_Extension::$powered_by ) ) : |
| 525 |
$output .= '<small class="nx-branding">'; |
| 526 |
$output .= '<svg width="12px" height="16px" viewBox="0 0 387 392" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><desc>Created with Sketch.</desc><defs></defs><g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="NotificationX_final" transform="translate(-1564.000000, -253.000000)"><g id="Group" transform="translate(1564.000000, 253.000000)"><path d="M135.45,358.68 C173.45,358.68 211.27,358.68 249.07,358.68 C247.02,371.83 221.24,388.59 199.26,390.98 C173.92,393.73 143.23,378.38 135.45,358.68 Z" id="Shape" fill="#5614D5" fill-rule="nonzero"></path><path d="M372.31,305.79 C369.97,305.59 367.6,305.71 365.24,305.71 C359.63,305.7 354.02,305.71 347.08,305.71 C347.08,301.43 347.08,298.42 347.08,295.41 C347.07,248.75 347.25,202.09 346.91,155.43 C346.83,144.89 345.88,134.19 343.79,123.87 C326.39,37.9 239.94,-16.19 154.81,5.22 C86.84,22.31 37.91,84.26 38.19,154.7 C38.36,197.12 38.21,239.54 38.2,281.96 C38.2,285.8 38.18,297.79 38.16,305.7 C32.98,305.66 18.07,305.57 12.86,305.88 C5.13,306.33 -0.06,312.31 0.04,319.97 C0.14,327.43 5.08,332.74 12.67,333.42 C14.78,333.61 16.91,333.57 19.03,333.57 C134.74,333.61 250.46,333.64 366.17,333.66 C368.29,333.66 370.42,333.69 372.53,333.48 C380.01,332.73 385.14,327.23 385.28,319.95 C385.41,312.58 379.86,306.44 372.31,305.79 Z" id="Shape" fill="#5614D5" fill-rule="nonzero"></path><circle id="Oval" fill="#836EFF" fill-rule="nonzero" cx="281.55" cy="255.92" r="15.49"></circle><path d="M295.67,140.1 L295.91,139.94 C295.7,138.63 295.52,137.29 295.27,136.02 C285.87,89.57 245.83,55.34 198.79,52.53 C198.73,52.53 198.67,52.52 198.61,52.52 C196.59,52.4 194.57,52.32 192.53,52.32 C192.48,52.32 192.44,52.32 192.39,52.32 C192.34,52.32 192.3,52.32 192.25,52.32 C190.21,52.32 188.18,52.4 186.17,52.52 C186.11,52.52 186.05,52.53 185.99,52.53 C138.95,55.34 98.91,89.57 89.51,136.02 C89.25,137.29 89.07,138.63 88.87,139.94 L89.11,140.1 C88.2,145.6 87.72,151.22 87.74,156.9 C87.76,161.42 87.77,256.77 87.78,269.74 L119.91,304.42 C119.91,280.14 119.9,170.57 119.85,156.78 C119.72,124.18 142.81,94.69 174.76,86.66 C177.41,85.99 180.09,85.5 182.78,85.13 C183.23,85.07 183.67,85 184.13,84.95 C185.15,84.83 186.17,84.74 187.18,84.66 C188.64,84.56 190.1,84.48 191.58,84.47 C191.85,84.47 192.12,84.45 192.39,84.44 C192.66,84.44 192.93,84.46 193.2,84.47 C194.68,84.48 196.14,84.56 197.6,84.66 C198.62,84.74 199.64,84.83 200.65,84.95 C201.1,85 201.55,85.07 202,85.13 C204.69,85.5 207.37,85.99 210.02,86.66 C241.96,94.69 265.06,124.19 264.93,156.78 C264.91,161.95 264.9,207.07 264.89,228.18 L297.03,206.73 C297.03,194.5 297.04,158.28 297.04,156.91 C297.06,151.21 296.59,145.6 295.67,140.1 Z" id="Shape" fill="#836EFF" fill-rule="nonzero"></path><path d="M31.94,305.72 C25.58,305.85 19.2,305.51 12.86,305.88 C5.13,306.33 -0.06,312.31 0.04,319.97 C0.14,327.43 5.08,332.74 12.67,333.42 C14.78,333.61 16.91,333.57 19.03,333.57 C134.74,333.61 250.45,333.63 366.17,333.66 C368.29,333.66 370.42,333.69 372.53,333.48 C380.01,332.73 385.14,327.23 385.28,319.95 C385.42,312.58 379.87,306.45 372.32,305.79 C369.98,305.59 367.61,305.71 365.25,305.71 C359.64,305.7 354.03,305.71 347.09,305.71 C347.09,301.43 347.09,298.42 347.09,295.41 C347.08,254.74 347.2,214.07 347.01,173.41 L131.62,317.03 L53.58,232.81 L87.05,202.02 L138.72,257.62 L343.2,121.26 C324.59,36.81 239.08,-15.98 154.82,5.21 C86.85,22.3 37.92,84.25 38.2,154.69 C38.37,197.11 38.22,239.53 38.21,281.95 C38.21,287.84 38.3,293.74 38.16,299.62" id="Shape"></path><path d="M346.91,155.42 C346.95,161.41 346.97,167.41 347,173.4 L386.14,147.41 L360.9,109.57 L343.2,121.26 C343.39,122.13 343.62,122.98 343.8,123.85 C345.88,134.18 346.84,144.89 346.91,155.42 Z" id="Shape" fill="#00F9AC" fill-rule="nonzero"></path><path d="M87.05,202.03 L53.58,232.82 L131.62,317.04 L347,173.41 C346.97,167.42 346.96,161.42 346.91,155.43 C346.83,144.89 345.88,134.19 343.79,123.87 C343.61,122.99 343.39,122.14 343.19,121.28 L138.72,257.63 L87.05,202.03 Z" id="Shape"></path><path d="M87.05,202.03 L53.58,232.82 L131.62,317.04 L347,173.41 C346.97,167.42 346.96,161.42 346.91,155.43 C346.83,144.89 345.88,134.19 343.79,123.87 C343.61,122.99 343.39,122.14 343.19,121.28 L138.72,257.63 L87.05,202.03 Z" id="Shape" fill="#21D8A3" fill-rule="nonzero" opacity="0.9"></path></g></g></g></svg>'; |
| 527 |
$output .= ' by <a href="'. NOTIFICATIONX_PLUGIN_URL .'?utm_source='. urlencode( home_url() ) .'&utm_medium=notificationx_referrer" target="_blank" class="nx-powered-by">NotificationX</a>'; |
| 528 |
$output .= '</small>'; |
| 529 |
endif; |
| 530 |
$output .= '</div>'; |
| 531 |
$output .= '</div>'; |
| 532 |
$output .= '</div>'; |
| 533 |
|
| 534 |
return $output; |
| 535 |
} |
| 536 |
|
| 537 |
public static function get_post_meta( $post_id, $key, $single = true ) { |
| 538 |
return get_post_meta( $post_id, '_nx_meta_' . $key, $single ); |
| 539 |
} |
| 540 |
public static function update_post_meta( $post_id, $key, $value ) { |
| 541 |
update_post_meta( $post_id, '_nx_meta_' . $key, $value ); |
| 542 |
} |
| 543 |
} |