/**
  * Create a data comment with data for a potential new subscriber.
  *
  * @since 1.0.0
  *
  * @param Prompt_Interface_Subscribable[]|Prompt_Interface_Subscribable $lists
  * @param string $email
  * @param array $user_data
  */
 public function save_subscription_data($lists, $email, $user_data = array())
 {
     $remote_address = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
     $comment_id = wp_insert_comment(array('comment_author_email' => $email, 'comment_author_IP' => preg_replace('/[^0-9a-fA-F:., ]/', '', $remote_address), 'comment_agent' => 'Postmatic/' . Prompt_Core::version(), 'comment_content' => serialize($lists), 'comment_type' => self::$comment_type, 'comment_approved' => 'Postmatic'));
     if (!empty($user_data)) {
         add_comment_meta($comment_id, self::$user_data_meta_key, $user_data);
     }
     $this->keys = array($comment_id);
 }
예제 #2
0
 /**
  * @param array $properties {
  *      Script properties
  *      @type string $handle Unique script identifier
  *      @type string $path Path to script from plugin root
  *      @type array  $dependencies Optional dependencies
  *      @type string $version Defaults to plugin version
  *      @type boolean $in_footer Defaults to true
  * }
  */
 public function __construct($properties)
 {
     $defaults = array('dependencies' => array(), 'version' => Prompt_Core::version(), 'in_footer' => true);
     $properties = wp_parse_args($properties, $defaults);
     foreach ($properties as $name => $value) {
         $this->{$name} = $value;
     }
     $suffix = '.min';
     if (defined('WP_SCRIPT_DEBUG') and WP_SCRIPT_DEBUG) {
         $suffix = '';
     }
     if (!file_exists(Prompt_Core::$dir_path . '/version')) {
         $suffix = '';
     }
     if ($suffix) {
         $this->path = preg_replace('/(\\.[^\\.]*$)/', $suffix . '\\1', $this->path);
     }
     $this->url = path_join(Prompt_Core::$url_path, $this->path);
 }
예제 #3
0
 public function __construct()
 {
     $this->prompt_version = Prompt_Core::version($full = true);
     $this->prompt_options = array_diff_key(Prompt_Core::$options->get(), array('prompt_key' => ''));
     $this->php_version = phpversion();
     $this->php_extensions = get_loaded_extensions();
     $this->wp_version = $GLOBALS['wp_version'];
     $this->db_version = $GLOBALS['wpdb']->db_version();
     $this->siteurl = get_option('siteurl');
     $this->is_multisite = is_multisite();
     $this->active_plugins = get_option('active_plugins');
     $this->active_sitewide_plugins = get_option('active_sitewide_plugins');
     $this->plugins = get_plugins();
     $this->theme = array();
     $theme = wp_get_theme();
     $theme_fields = array('Name', 'ThemeURI', 'Author', 'AuthorURI', 'Version', 'Template');
     foreach ($theme_fields as $field) {
         $this->theme[$field] = $theme->get($field);
     }
 }
예제 #4
0
 /**
  * Enqueue scripts and styles.
  *
  * @since 1.0.0
  */
 public function page_head()
 {
     wp_enqueue_media();
     wp_enqueue_style('prompt-admin', path_join(Prompt_Core::$url_path, 'css/admin.css'), array(), Prompt_Core::version());
     wp_enqueue_style('datetimepicker', 'https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.4.5/jquery.datetimepicker.min.css', array(), '2.4.5');
     wp_enqueue_script('datetimepicker', 'https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.4.5/jquery.datetimepicker.min.js', array(), '2.4.5');
     $script = new Prompt_Script(array('handle' => 'prompt-options-page', 'path' => 'js/options-page.js', 'dependencies' => array('jquery-ui-tabs', 'datetimepicker')));
     $script->enqueue();
     $script->localize('prompt_options_page_env', array('email_header_image_prompt' => __('Choose an email header image', 'Postmatic')));
 }
예제 #5
0
 /**
  * Get the plugin version.
  *
  * @param bool $full If true, append build or commit. Default false.
  * @return string
  */
 public static function version($full = false)
 {
     if ($full and self::$full_version) {
         return self::$full_version;
     }
     if (!$full and self::$version) {
         return self::$version;
     }
     $build_file = path_join(self::$dir_path, 'version');
     if (file_exists($build_file)) {
         self::$full_version = file_get_contents($build_file);
         $parts = explode('-', self::$full_version);
         self::$version = $parts[0];
         return $full ? self::$full_version : self::$version;
     }
     // This is not a built package, dig around some more
     if (!function_exists('get_plugin_data')) {
         require_once ABSPATH . '/wp-admin/includes/plugin.php';
     }
     $plugin_data = get_plugin_data(self::$dir_path . '/postmatic.php');
     self::$version = $plugin_data['Version'];
     if (!$full) {
         return self::$version;
     }
     if (getenv('CI')) {
         return self::$version . '-' . getenv('CI_COMMIT_ID');
     }
     $head = path_join(self::$dir_path, '.git/HEAD');
     if (!file_exists($head)) {
         return self::$version;
     }
     $ref = path_join(self::$dir_path, '.git/' . trim(substr(file_get_contents($head), 5)));
     if (!file_exists($ref)) {
         return self::$version;
     }
     self::$full_version = trim(self::$version . '-' . file_get_contents($ref));
     return self::$full_version;
 }
예제 #6
0
 /**
  * Make a method agnostic request
  *
  * @since 0.1.0
  *
  * @param string $endpoint
  * @param array $request
  * @return array|WP_Error The implementation return value, a wp_remote_request() array by default.
  */
 public function send($endpoint, $request = array())
 {
     $url = $this->make_url($endpoint);
     $request = wp_parse_args($request, $this->defaults);
     if (!isset($request['headers'])) {
         $request['headers'] = array();
     }
     if (!isset($request['headers']['Authorization'])) {
         $request['headers']['Authorization'] = 'Basic ' . base64_encode('api:' . $this->key);
     }
     if (!isset($request['headers']['X-Prompt-Core-Version'])) {
         $request['headers']['X-Prompt-Core-Version'] = Prompt_Core::version($full = true);
     }
     $default_timeout = defined('PROMPT_API_TIMEOUT') ? PROMPT_API_TIMEOUT : 30;
     if (!isset($request['timeout'])) {
         $request['timeout'] = $default_timeout;
     }
     $reply = call_user_func($this->implementation, $url, $request);
     if (!is_wp_error($reply) and isset($reply['response']['code']) and 410 == $reply['response']['code']) {
         Prompt_Core::$options->set('upgrade_required', true);
     }
     return $reply;
 }