Пример #1
0
 public static function es_prepare_notification($post_status, $original_post_status, $post_id)
 {
     if ($post_status == 'publish' && $original_post_status != 'publish') {
         $notification = array();
         // $post_id is Object type containing the post information
         // Thus we need to get post_id from $post_id object
         if (is_numeric($post_id)) {
             $post_id = $post_id;
         } else {
             if (is_object($post_id)) {
                 $post_id = $post_id->ID;
             } else {
                 $post_id = $post_id;
             }
         }
         $notification = es_cls_notification::es_notification_prepare($post_id);
         if (count($notification) > 0) {
             $template = $notification[0]["es_note_templ"];
             $subscribers = array();
             $subscribers = es_cls_notification::es_notification_subscribers($notification);
             if (count($subscribers) > 0) {
                 es_cls_sendmail::es_sendmail("notification", $template, $subscribers, "notification", $post_id);
             }
         }
     }
 }
    }
    //	No errors found, we can add this Group to the table
    if ($es_error_found == FALSE) {
        $action = false;
        $listcategory = "";
        $total = count($es_note_cat);
        if ($total > 0) {
            for ($i = 0; $i < $total; $i++) {
                $listcategory = $listcategory . " ##" . $es_note_cat[$i] . "## ";
                if ($i != $total - 1) {
                    $listcategory = $listcategory . "--";
                }
            }
        }
        $form['es_note_cat'] = $listcategory;
        $action = es_cls_notification::es_notification_ins($form, $action = "insert");
        if ($action) {
            $es_success = __('Notification was successfully created.', 'email-subscribers');
        }
        // Reset the form fields
        $form = array('es_note_id' => '', 'es_note_cat' => '', 'es_note_group' => '', 'es_note_templ' => '', 'es_note_status' => '');
    }
}
if ($es_error_found == TRUE && isset($es_errors[0]) == TRUE) {
    ?>
<div class="error fade"><p><strong><?php 
    echo $es_errors[0];
    ?>
</strong></p></div><?php 
}
if ($es_error_found == FALSE && strlen($es_success) > 0) {
    $form['es_note_id'] = isset($_POST['es_note_id']) ? $_POST['es_note_id'] : '';
    //	No errors found, we can add this Group to the table
    if ($es_error_found == FALSE) {
        $action = false;
        $listcategory = "";
        $total = count($es_note_cat);
        if ($total > 0) {
            for ($i = 0; $i < $total; $i++) {
                $listcategory = $listcategory . " ##" . $es_note_cat[$i] . "## ";
                if ($i != $total - 1) {
                    $listcategory = $listcategory . "--";
                }
            }
        }
        $form['es_note_cat'] = $listcategory;
        $action = es_cls_notification::es_notification_ins($form, $action = "update");
        if ($action == "sus") {
            $es_success = __('Notification was successfully updated.', 'email-subscribers');
        }
    }
}
if ($es_error_found == TRUE && isset($es_errors[0]) == TRUE) {
    ?>
<div class="error fade"><p><strong><?php 
    echo $es_errors[0];
    ?>
</strong></p></div><?php 
}
if ($es_error_found == FALSE && strlen($es_success) > 0) {
    ?>
	<div class="updated fade">
Пример #4
0
</h2>
	<h3><?php 
_e('Notification', 'email-subscribers');
?>
  
	<a class="add-new-h2" href="<?php 
echo ES_ADMINURL;
?>
?page=es-notification&amp;ac=add"><?php 
_e('Add New', 'email-subscribers');
?>
</a></h3>
    <div class="tool-box">
	<?php 
$myData = array();
$myData = es_cls_notification::es_notification_select(0);
?>
	<form name="frm_es_display" method="post">
      <table width="100%" class="widefat" id="straymanage">
        <thead>
          <tr>
			<th scope="col"><?php 
_e('Mail Subject', 'email-subscribers');
?>
</th>
			<th scope="col"><?php 
_e('Subscribers Group', 'email-subscribers');
?>
</th>
			<th scope="col"><?php 
_e('Categories / Custom Post', 'email-subscribers');
 public static function es_notifications_default()
 {
     $result = es_cls_notification::es_notification_count(0);
     if ($result == 0) {
         $form["es_note_group"] = "Public";
         $form["es_note_status"] = "Enable";
         $form["es_note_templ"] = "1";
         $listcategory = "";
         $args = array('hide_empty' => 0, 'orderby' => 'name', 'order' => 'ASC');
         $categories = get_categories($args);
         $total = count($categories);
         $i = 1;
         foreach ($categories as $category) {
             $listcategory = $listcategory . " ##" . $category->cat_name . "## ";
             if ($i < $total) {
                 $listcategory = $listcategory . "--";
             }
             $i = $i + 1;
         }
         $form["es_note_cat"] = $listcategory;
         es_cls_notification::es_notification_ins($form, "insert");
     }
     return true;
 }