Ejemplo n.º 1
0
 /**
  * Initialization function, similar to __construct()
  *
  * @since 1.00
  *
  * @return	void
  */
 public static function initialize()
 {
     if ('disabled' == MLACore::mla_get_option(MLACore::MLA_FEATURED_IN_TUNING)) {
         MLACore::$process_featured_in = false;
     }
     if ('disabled' == MLACore::mla_get_option(MLACore::MLA_INSERTED_IN_TUNING)) {
         MLACore::$process_inserted_in = false;
     }
     if ('disabled' == MLACore::mla_get_option(MLACore::MLA_GALLERY_IN_TUNING)) {
         MLACore::$process_gallery_in = false;
     }
     if ('disabled' == MLACore::mla_get_option(MLACore::MLA_MLA_GALLERY_IN_TUNING)) {
         MLACore::$process_mla_gallery_in = false;
     }
 }
Ejemplo n.º 2
0
 /**
  * Initialization function, similar to __construct()
  *
  * @since 1.00
  *
  * @return	void
  */
 public static function initialize()
 {
     if ('disabled' == MLACore::mla_get_option(MLACoreOptions::MLA_FEATURED_IN_TUNING)) {
         MLACore::$process_featured_in = false;
     }
     if ('disabled' == MLACore::mla_get_option(MLACoreOptions::MLA_INSERTED_IN_TUNING)) {
         MLACore::$process_inserted_in = false;
     }
     if ('disabled' == MLACore::mla_get_option(MLACoreOptions::MLA_GALLERY_IN_TUNING)) {
         MLACore::$process_gallery_in = false;
     }
     if ('disabled' == MLACore::mla_get_option(MLACoreOptions::MLA_MLA_GALLERY_IN_TUNING)) {
         MLACore::$process_mla_gallery_in = false;
     }
     /*
      * Look for redirects from the Media/Edit Media screen when it was picked from the
      * "Edit" rollover action on the Media/Assistant submenu
      */
     if (isset($_REQUEST['mla_source'])) {
         add_filter('wp_redirect', 'MLACore::mla_wp_redirect_filter', 10, 2);
     }
     /*
      * Override the cookie-based Attachment Display Settings, if desired
      * consider ignoring 'action' => 'send-attachment-to-editor',
      */
     if ('checked' === MLACore::mla_get_option(MLACoreOptions::MLA_MEDIA_MODAL_APPLY_DISPLAY_SETTINGS)) {
         $image_default_align = get_option('image_default_align');
         $image_default_link_type = get_option('image_default_link_type');
         $image_default_size = get_option('image_default_size');
         if (!(empty($image_default_align) && empty($image_default_link_type) && empty($image_default_size))) {
             $user_id = get_current_user_id();
             $not_super_admin = !(is_super_admin() && !is_user_member_of_blog());
             if ($user_id && $not_super_admin) {
                 if (isset($_COOKIE['wp-settings-' . $user_id])) {
                     $cookie = preg_replace('/[^A-Za-z0-9=&_]/', '', $_COOKIE['wp-settings-' . $user_id]);
                 } else {
                     $cookie = (string) get_user_option('user-settings', $user_id);
                 }
                 parse_str($cookie, $cookie_array);
                 $cookie_align = isset($cookie_array['align']) ? $cookie_array['align'] : '';
                 $cookie_urlbutton = isset($cookie_array['urlbutton']) ? $cookie_array['urlbutton'] : '';
                 $cookie_imgsize = isset($cookie_array['imgsize']) ? $cookie_array['imgsize'] : '';
                 $changed = false;
                 if (!empty($image_default_align) && $cookie_align !== $image_default_align) {
                     $cookie_array['align'] = $image_default_align;
                     $changed = true;
                 }
                 if (!empty($image_default_link_type) && $cookie_urlbutton !== $image_default_link_type) {
                     $cookie_array['urlbutton'] = $image_default_link_type;
                     $changed = true;
                 }
                 if (!empty($image_default_size) && $cookie_imgsize !== $image_default_size) {
                     $cookie_array['imgsize'] = $image_default_size;
                     $changed = true;
                 }
                 if ($changed) {
                     $cookie = http_build_query($cookie_array, '', '&');
                     $current = time();
                     $secure = 'https' === parse_url(admin_url(), PHP_URL_SCHEME);
                     setcookie('wp-settings-' . $user_id, $cookie, time() + YEAR_IN_SECONDS, SITECOOKIEPATH, null, $secure);
                     setcookie('wp-settings-time-' . $user_id, $current, $current + YEAR_IN_SECONDS, SITECOOKIEPATH, null, $secure);
                     $_COOKIE['wp-settings-' . $user_id] = $cookie;
                     $_COOKIE['wp-settings-time-' . $user_id] = $current;
                 }
             }
         }
     }
     // MLA_MEDIA_MODAL_APPLY_DISPLAY_SETTINGS
     /*
      * Hook wp_enqueue_media() so we can add MLA enhancements, if requested
      */
     if ('checked' == MLACore::mla_get_option(MLACoreOptions::MLA_MEDIA_MODAL_TOOLBAR)) {
         add_filter('media_view_settings', 'MLACore::mla_media_view_settings_filter', 10, 2);
     }
 }
Ejemplo n.º 3
0
 /**
  * Save General settings to the options table
  *
  * @since 0.1
  *
  * @uses $_REQUEST
  *
  * @return	array	Message(s) reflecting the results of the operation
  */
 private static function _save_general_settings()
 {
     $message_list = '';
     foreach (MLACore::$mla_option_definitions as $key => $value) {
         if ('general' == $value['tab']) {
             switch ($key) {
                 case MLACore::MLA_FEATURED_IN_TUNING:
                     MLACore::$process_featured_in = 'disabled' != $_REQUEST[MLA_OPTION_PREFIX . $key];
                     break;
                 case MLACore::MLA_INSERTED_IN_TUNING:
                     MLACore::$process_inserted_in = 'disabled' != $_REQUEST[MLA_OPTION_PREFIX . $key];
                     break;
                 case MLACore::MLA_GALLERY_IN_TUNING:
                     MLACore::$process_gallery_in = 'disabled' != $_REQUEST[MLA_OPTION_PREFIX . $key];
                     if ('refresh' == $_REQUEST[MLA_OPTION_PREFIX . $key]) {
                         MLAQuery::mla_flush_mla_galleries(MLACore::MLA_GALLERY_IN_TUNING);
                         /* translators: 1: reference type, e.g., Gallery in */
                         $message_list .= "<br>" . sprintf(_x('%1$s - references updated.', 'message_list', 'media-library-assistant'), __('Gallery in', 'media-library-assistant')) . "\r\n";
                         $_REQUEST[MLA_OPTION_PREFIX . $key] = 'cached';
                     }
                     break;
                 case MLACore::MLA_MLA_GALLERY_IN_TUNING:
                     MLACore::$process_mla_gallery_in = 'disabled' != $_REQUEST[MLA_OPTION_PREFIX . $key];
                     if ('refresh' == $_REQUEST[MLA_OPTION_PREFIX . $key]) {
                         MLAQuery::mla_flush_mla_galleries(MLACore::MLA_MLA_GALLERY_IN_TUNING);
                         /* translators: 1: reference type, e.g., Gallery in */
                         $message_list .= "<br>" . sprintf(_x('%1$s - references updated.', 'message_list', 'media-library-assistant'), __('MLA Gallery in', 'media-library-assistant')) . "\r\n";
                         $_REQUEST[MLA_OPTION_PREFIX . $key] = 'cached';
                     }
                     break;
                 case MLACore::MLA_TAXONOMY_SUPPORT:
                     /*
                      * Replace missing "checkbox" arguments with empty arrays,
                      * denoting that all of the boxes are unchecked.
                      */
                     if (!isset($_REQUEST['tax_support'])) {
                         $_REQUEST['tax_support'] = array();
                     }
                     if (!isset($_REQUEST['tax_quick_edit'])) {
                         $_REQUEST['tax_quick_edit'] = array();
                     }
                     if (!isset($_REQUEST['tax_term_search'])) {
                         $_REQUEST['tax_term_search'] = array();
                     }
                     if (!isset($_REQUEST['tax_flat_checklist'])) {
                         $_REQUEST['tax_flat_checklist'] = array();
                     }
                     if (!isset($_REQUEST['tax_checked_on_top'])) {
                         $_REQUEST['tax_checked_on_top'] = array();
                     }
                     break;
                 case MLACore::MLA_SEARCH_MEDIA_FILTER_DEFAULTS:
                     /*
                      * Replace missing "checkbox" arguments with empty arrays,
                      * denoting that all of the boxes are unchecked.
                      */
                     if (!isset($_REQUEST['search_fields'])) {
                         $_REQUEST['search_fields'] = array();
                     }
                     break;
                 default:
                     //	ignore everything else
             }
             // switch
             $message_list .= self::mla_update_option_row($key, $value);
         }
         // general option
     }
     // foreach mla_options
     $page_content = array('message' => __('General settings saved.', 'media-library-assistant') . "\r\n", 'body' => '');
     /*
      * Uncomment this for debugging.
      */
     // $page_content['message'] .= $message_list;
     return $page_content;
 }