function __construct($plugin_file_path, $aws) { $this->plugin_title = __('WP AWS Zencoder', 'waz'); $this->plugin_menu_title = __('Zencoder', 'waz'); $this->plugin_slug = 'wp-aws-zencoder'; // lets do this before anything else gets loaded $this->require_zencoder(); parent::__construct($plugin_file_path); $this->aws = $aws; $this->zen = new Services_Zencoder($this->get_api_key()); // Admin add_action('aws_admin_menu', array($this, 'admin_menu')); // Whenever a post is saved, check if any attached media should be encoded add_action('save_post', array($this, 'save_post'), 1000); add_action('edit_post', array($this, 'save_post'), 1000); add_action('publish_post', array($this, 'save_post'), 1000); add_action('maj_post_attached_to_media', array($this, 'save_post'), 1000); add_action('maj_video_updated', array($this, 'save_post'), 1000); // When student media uploader videos are uploaded, encode them add_filter('maj_media_import', [$this, 'student_media_uploader_send_for_encoding'], 1000); // Let's delete the attachments add_filter('delete_attachment', array($this, 'delete_attachment'), 20); // Rewrites add_action('wp_loaded', array($this, 'flush_rules')); add_filter('rewrite_rules_array', array($this, 'rewrite_rules')); add_filter('query_vars', array($this, 'query_vars')); // Catch notifications from zencoder add_action('pre_get_posts', array($this, 'zencoder_notification')); }
function get_setting($key) { $settings = $this->get_settings(); // If legacy setting set, migrate settings if (isset($settings['wp-uploads']) && $settings['wp-uploads'] && in_array($key, array('copy-to-s3', 'serve-from-s3'))) { return '1'; } // Default object prefix if ('object-prefix' == $key && !isset($settings['object-prefix'])) { $uploads = wp_upload_dir(); $parts = parse_url($uploads['baseurl']); return substr($parts['path'], 1) . '/'; } return parent::get_setting($key); }
function __construct($plugin_file_path) { parent::__construct($plugin_file_path); do_action('aws_init', $this); if (is_admin()) { do_action('aws_admin_init', $this); } if (is_multisite()) { add_action('network_admin_menu', array($this, 'admin_menu')); $this->plugin_permission = 'manage_network_options'; } else { add_action('admin_menu', array($this, 'admin_menu')); $this->plugin_permission = 'manage_options'; } $this->plugin_title = __('Amazon Web Services', 'amazon-web-services'); $this->plugin_menu_title = __('AWS', 'amazon-web-services'); }
function __construct($plugin_file_path) { $this->plugin_slug = 'amazon-web-services'; parent::__construct($plugin_file_path); do_action('aws_init', $this); if (is_admin()) { do_action('aws_admin_init', $this); } if (is_multisite()) { add_action('network_admin_menu', array($this, 'admin_menu')); $this->plugin_permission = 'manage_network_options'; } else { add_action('admin_menu', array($this, 'admin_menu')); $this->plugin_permission = 'manage_options'; } $this->plugin_title = __('Amazon Web Services', 'amazon-web-services'); $this->plugin_menu_title = __('AWS', 'amazon-web-services'); load_plugin_textdomain('amazon-web-services', false, dirname(plugin_basename($plugin_file_path)) . '/languages/'); }
function get_setting($key) { $settings = $this->get_settings(); // If legacy setting set, migrate settings if (isset($settings['wp-uploads']) && $settings['wp-uploads'] && in_array($key, array('copy-to-s3', 'serve-from-s3'))) { return '1'; } // Default object prefix if ('object-prefix' == $key && !isset($settings['object-prefix'])) { $uploads = wp_upload_dir(); $parts = parse_url($uploads['baseurl']); return substr($parts['path'], 1) . '/'; } if ('bucket' == $key && defined('AS3CF_BUCKET')) { $value = AS3CF_BUCKET; } else { $value = parent::get_setting($key); } return apply_filters('as3cf_setting_' . $key, $value); }
/** * Setter for a plugin setting with custom hooks * * @param string $key * @param mixed $value */ function set_setting($key, $value) { // Run class specific hooks before the setting is saved $this->pre_set_setting($key, $value); $value = apply_filters('as3cf_set_setting_' . $key, $value); // Remove disallowed characters from custom domain if ('cloudfront' === $key) { $value = $this->sanitize_custom_domain($value); } parent::set_setting($key, $value); }
/** * Setter for a plugin setting with custom hooks * * @param string $key * @param mixed $value */ function set_setting($key, $value) { // Run class specific hooks before the setting is saved $this->pre_set_setting($key, $value); $value = apply_filters('as3cf_set_setting_' . $key, $value); parent::set_setting($key, $value); }
/** * Accessor for a plugin setting with conditions to defaults and upgrades * * @param string $key * @param string $default * * @return int|mixed|string|void */ function get_setting($key, $default = '') { // use settings from $_POST when generating URL preview via AJAX if (isset($_POST['action']) && 'as3cf-get-url-preview' == sanitize_key($_POST['action'])) { // input var okay $value = 0; if (isset($_POST[$key])) { // input var okay $value = $_POST[$key]; // input var okay if (is_array($value)) { // checkbox is checked $value = 1; } } return $value; } $settings = $this->get_settings(); // If legacy setting set, migrate settings if (isset($settings['wp-uploads']) && $settings['wp-uploads'] && in_array($key, array('copy-to-s3', 'serve-from-s3'))) { return '1'; } // Default object prefix if ('object-prefix' == $key && !isset($settings['object-prefix'])) { return $this->get_default_object_prefix(); } // Default use year and month folders if ('use-yearmonth-folders' == $key && !isset($settings['use-yearmonth-folders'])) { return get_option('uploads_use_yearmonth_folders'); } // Default enable object prefix - enabled unless path is empty if ('enable-object-prefix' == $key) { if (isset($settings['enable-object-prefix']) && '0' == $settings['enable-object-prefix']) { return 0; } if (isset($settings['object-prefix']) && '' == trim($settings['object-prefix'])) { return 0; } else { return 1; } } // Region of bucket if not already retrieved if ('region' == $key && !isset($settings['region'])) { $bucket = $this->get_setting('bucket'); $region = $this->get_bucket_region($bucket); if (is_wp_error($region)) { $region = ''; } return $region; } // Region of bucket translation if ('region' == $key && isset($settings['region'])) { return $this->translate_region($settings['region']); } // Domain setting since 0.8 if ('domain' == $key && !isset($settings['domain'])) { if ($this->get_setting('cloudfront')) { $domain = 'cloudfront'; } elseif ($this->get_setting('virtual-host')) { $domain = 'virtual-host'; } elseif ($this->use_ssl()) { $domain = 'path'; } else { $domain = 'subdomain'; } return $domain; } // SSL radio buttons since 0.8 if ('ssl' == $key && !isset($settings['ssl'])) { if ($this->get_setting('force-ssl', false)) { $ssl = 'https'; } else { $ssl = 'request'; } return $ssl; } if ('bucket' == $key && defined('AS3CF_BUCKET')) { return AS3CF_BUCKET; } $value = parent::get_setting($key, $default); return apply_filters('as3cf_setting_' . $key, $value); }