public static function add_test_subscribers($post)
 {
     if (isset($post['count'])) {
         $count = $post['count'];
         for ($c = 0; $c < $count; $c++) {
             EZP_CS_Query_Utility::add_new_subscriber("person-{$c}", "{$c}@gmail.com");
         }
     } else {
         EZP_CS_Utility::debug('Count parameter not set for add_test_subscribers!');
     }
 }
 public static function add_new_subscriber($friendly_name, $email_address)
 {
     $error_text = null;
     $friendly_name = sanitize_text_field($friendly_name);
     $email_address = sanitize_text_field($email_address);
     if (strlen($friendly_name) > 255) {
         $error_text = EZP_CS_Utility::__('Name is too long') . '.';
     }
     if (!is_email($email_address) || strlen($email_address) > 255) {
         $error_text = EZP_CS_Utility::__('Email address is not valid') . '.';
     }
     // Note: If error with entity, silently let it go. No sense telling user, just admin.
     if ($error_text == null) {
         $contact = new EZP_Contact_Entity();
         $contact->friendly_name = $friendly_name;
         if ($contact->save()) {
             $email = new EZP_Email_Entity();
             $email->email_address = $email_address;
             $email->contact_id = $contact->id;
             if ($email->save()) {
                 $cse = new EZP_CS_Subscriber_Entity();
                 $cse->contact_id = $contact->id;
                 if (!$cse->save()) {
                     EZP_CS_Utility::debug('add_new_subscriber:Error saving subscriber entity to deleting email and contact');
                     $email->delete();
                     $contact->delete();
                 }
             } else {
                 EZP_CS_Utility::debug('add_new_subscriber:Error saving email entity so deleting contact');
                 $contact->delete();
             }
         } else {
             EZP_CS_Utility::debug('add_new_subscriber:Error saving contact entity');
         }
     }
     return $error_text;
 }
<!--<script type="text/javascript" src="<?php 
echo EZP_CS_Utility::$PLUGIN_URL . '/jquery-plugins/simple-modal/jquery.simplemodal.1.4.4.min.js?' . EZP_CS_Constants::PLUGIN_VERSION;
?>
"></script>-->

<?php 
$action_updated = null;
$global = EZP_CS_Global_Entity::get_instance();
$set_index = $global->active_set_index;
$set = EZP_CS_Set_Entity::get_by_id($set_index);
$display = EZP_CS_Display_Entity::get_by_id($set->display_index);
$config = EZP_CS_Config_Entity::get_by_id($global->config_index);
$error_string = "";
if (isset($_POST['action']) && $_POST['action'] == 'save') {
    check_admin_referer('easy-pie-coming-soon-save-display');
    EZP_CS_Utility::debug('past admin check');
    // Artificially set the bools since they aren't part of the postback
    $display->background_tiling_enabled = "false";
    $error_string = $display->set_post_variables($_POST);
    if ($error_string == "") {
        $action_updated = $display->save();
    }
}
?>

<?php 
wp_nonce_field('easy-pie-coming-soon-save-display');
?>
<input type="hidden" name="action" value="save"/>
<?php 
//EZP_CS_Utility::display_admin_notice($config->coming_soon_mode_on);
 public static function get_by_unique_field_and_type($field_name, $field_value, $class_name, $base_table_name)
 {
     global $wpdb;
     $table_name = $wpdb->prefix . $base_table_name;
     $query_string = "SELECT * FROM " . $table_name;
     $query_string .= " WHERE {$field_name} = %d;";
     $prepped = $wpdb->prepare($query_string, $field_value);
     $row = $wpdb->get_row($prepped);
     if ($row != NULL) {
         return self::get_instance_from_row($row, $class_name, $table_name);
     } else {
         EZP_CS_Utility::debug("get_by_unique_field_and_type: row is null for {$table_name}, {$field_name}, {$field_value}");
         return null;
     }
 }
Exemple #5
0
 public static function uninstall()
 {
     EZP_CS_Utility::debug("uninstall");
 }
 public static function debug_dump($message, $object)
 {
     EZP_CS_Utility::debug($message . ":" . var_export($object, true));
 }
 /**
  * 
  * @param type $template_key
  * @return EZP_CS_Display_Entity
  */
 public static function create_from_template($template_key)
 {
     EZP_CS_Utility::debug("copying from template {$template_key}");
     $template_directory = EZP_CS_Utility::$MINI_THEMES_TEMPLATE_DIRECTORY . $template_key;
     $metadata_path = $template_directory . "/display.json";
     $display_json = file_get_contents($metadata_path);
     $mixed = json_decode($display_json);
     EZP_CS_Utility::debug_dump("mixed from template", $mixed);
     $new = self::create_from_mixed($mixed);
     EZP_CS_Utility::debug_dump("after copy from template", $new);
     return $new;
 }
 public static function get_by_id_and_type($id, $type, $table_name = self::DEFAULT_TABLE_NAME)
 {
     global $wpdb;
     $table_name = $wpdb->prefix . $table_name;
     $query_string = "SELECT * FROM " . $table_name;
     $query_string .= " WHERE id = %d;";
     $prepped = $wpdb->prepare($query_string, $id);
     $row = $wpdb->get_row($prepped);
     if ($row != NULL) {
         $instance = new $type();
         $instance->id = $row->id;
         $instance->type = $row->type;
         $instance->table_name = $table_name;
         $data = json_decode($row->data);
         foreach ($data as $property_name => $property_value) {
             $instance->{$property_name} = $property_value;
         }
         return $instance;
     } else {
         EZP_CS_Utility::debug('get_by_id_and_type: row is null');
         return null;
     }
 }