コード例 #1
0
 /**
  * Load style and markup templates to $mla_custom_templates
  *
  * @since 2.20
  *
  * @return	void
  */
 public static function mla_load_custom_templates()
 {
     MLAShortcode_Support::$mla_custom_templates = MLAData::mla_load_template('mla-custom-templates.tpl');
     /* 	
      * Load the default templates
      */
     if (is_null(MLAShortcode_Support::$mla_custom_templates)) {
         MLACore::mla_debug_add('<strong>mla_debug _load_option_templates()</strong> ' . __('error loading tpls/mla-option-templates.tpl', 'media-library-assistant'));
         return;
     } elseif (!MLAShortcode_Support::$mla_custom_templates) {
         MLACore::mla_debug_add('<strong>mla_debug _load_option_templates()</strong> ' . __('tpls/mla-option-templates.tpl not found', 'media-library-assistant'));
         MLAShortcode_Support::$mla_custom_templates = NULL;
         return;
     }
     /*
      * Add user-defined Style and Markup templates
      */
     $templates = MLACore::mla_get_option('style_templates');
     if (is_array($templates)) {
         foreach ($templates as $name => $value) {
             MLAShortcode_Support::$mla_custom_templates[$name . '-style'] = $value;
         }
         // foreach $templates
     }
     // is_array
     $templates = MLACore::mla_get_option('markup_templates');
     if (is_array($templates)) {
         foreach ($templates as $name => $value) {
             MLAShortcode_Support::$mla_custom_templates[$name . '-open-markup'] = $value['open'];
             MLAShortcode_Support::$mla_custom_templates[$name . '-row-open-markup'] = $value['row-open'];
             MLAShortcode_Support::$mla_custom_templates[$name . '-item-markup'] = $value['item'];
             MLAShortcode_Support::$mla_custom_templates[$name . '-row-close-markup'] = $value['row-close'];
             MLAShortcode_Support::$mla_custom_templates[$name . '-close-markup'] = $value['close'];
         }
         // foreach $templates
     }
     // is_array
 }
コード例 #2
0
 /**
  * Renders the Settings/Media Library Assistant "Language" tab
  *
  * @since 2.11
  *
  * @return	array	( 'message' => '', 'body' => '' )
  */
 public static function mla_render_language_tab()
 {
     $page_content = array('message' => '', 'body' => '<h3>Language</h3>');
     /*
      * Check for submit buttons to change or reset settings.
      * Initialize page messages and content.
      */
     if (!empty($_REQUEST['mla-language-options-save'])) {
         check_admin_referer(MLA::MLA_ADMIN_NONCE_ACTION, MLA::MLA_ADMIN_NONCE_NAME);
         $page_content = self::_save_language_settings();
     } elseif (!empty($_REQUEST['mla-language-options-reset'])) {
         check_admin_referer(MLA::MLA_ADMIN_NONCE_ACTION, MLA::MLA_ADMIN_NONCE_NAME);
         $page_content = self::_reset_language_settings();
     } else {
         $page_content = array('message' => '', 'body' => '');
     }
     if (!empty($page_content['body'])) {
         return $page_content;
     }
     $page_values = array('Language Options' => __('Language Options', 'media-library-assistant'), 'In this tab' => sprintf(__('In this tab you can find a number of options for controlling WPML-specific operations. Scroll down to find options for %1$s and %2$s. Be sure to click "Save Changes" at the bottom of the tab to save any changes you make.', 'media-library-assistant'), '<strong>' . __('Media/Assistant submenu table', 'media-library-assistant') . '</strong>', '<strong>' . __('Term Management', 'media-library-assistant') . '</strong>'), 'You can find' => sprintf(__('You can find more information about multilingual features in the %1$s section of the Documentation.', 'media-library-assistant'), '<a href="[+settingsURL+]?page=mla-settings-menu-documentation&amp;mla_tab=documentation#mla_language_tab" title="' . __('Language Options documentation', 'media-library-assistant') . '">' . __('WPML &amp; Polylang Multilingual Support; the MLA Language Tab', 'media-library-assistant') . '</a>'), 'settingsURL' => admin_url('options-general.php'), 'Save Changes' => __('Save Changes', 'media-library-assistant'), 'Delete Language options' => __('Delete Language options and restore default settings', 'media-library-assistant'), '_wpnonce' => wp_nonce_field(MLA::MLA_ADMIN_NONCE_ACTION, MLA::MLA_ADMIN_NONCE_NAME, true, false), '_wp_http_referer' => wp_referer_field(false), 'Go to Top' => __('Go to Top', 'media-library-assistant'), 'form_url' => admin_url('options-general.php') . '?page=mla-settings-menu-language&mla_tab=language', 'options_list' => '');
     $options_list = '';
     foreach (MLA_WPML::$mla_language_option_definitions as $key => $value) {
         if ('language' == $value['tab']) {
             $options_list .= MLASettings::mla_compose_option_row($key, $value, MLA_WPML::$mla_language_option_definitions);
         }
     }
     $page_values['options_list'] = $options_list;
     $page_template = MLAData::mla_load_template('admin-display-language-tab.tpl');
     $page_content['body'] = MLAData::mla_parse_template($page_template, $page_values);
     return $page_content;
 }
コード例 #3
0
 /**
  * Assemble the in-memory representation of the (read-only) Optional Upload MIME Types 
  *
  * @since 1.40
  *
  * @return	boolean	Success (true) or failure (false) of the operation
  */
 private static function _get_optional_upload_mime_templates()
 {
     if (NULL != self::$mla_optional_upload_mime_templates) {
         return true;
     }
     self::$mla_optional_upload_mime_templates = array();
     $template_array = MLAData::mla_load_template('mla-default-mime-types.tpl');
     if (isset($template_array['mla-optional-mime-types'])) {
         $mla_mime_types = preg_split('/[\\r\\n]+/', $template_array['mla-optional-mime-types']);
         $ID = 0;
         foreach ($mla_mime_types as $mla_type) {
             $array = explode(',', $mla_type);
             $slug = $array[0];
             if ($matched_type = self::mla_get_upload_mime($slug)) {
                 $core_type = $matched_type['core_type'];
                 $mla_type = $matched_type['mla_type'];
             } else {
                 $core_type = '';
                 $mla_type = '';
             }
             self::$mla_optional_upload_mime_templates[++$ID] = array('ID' => $ID, 'slug' => $slug, 'mime_type' => $array[1], 'core_type' => $core_type, 'mla_type' => $mla_type, 'description' => $array[2]);
         }
     }
     return true;
 }
コード例 #4
0
 /**
  * Build the hidden row templates for inline editing (quick and bulk edit)
  *
  * inspired by inline_edit() in wp-admin\includes\class-wp-posts-list-table.php.
  *
  * @since 0.20
  *
  * @param	object	MLA List Table object
  *
  * @return	string	HTML <form> markup for hidden rows
  */
 private static function _build_inline_edit_form($MLAListTable)
 {
     $taxonomies = get_object_taxonomies('attachment', 'objects');
     $hierarchical_taxonomies = array();
     $flat_taxonomies = array();
     foreach ($taxonomies as $tax_name => $tax_object) {
         if ($tax_object->hierarchical && $tax_object->show_ui && MLAOptions::mla_taxonomy_support($tax_name, 'quick-edit')) {
             $hierarchical_taxonomies[$tax_name] = $tax_object;
         } elseif ($tax_object->show_ui && MLAOptions::mla_taxonomy_support($tax_name, 'quick-edit')) {
             $flat_taxonomies[$tax_name] = $tax_object;
         }
     }
     $page_template_array = MLAData::mla_load_template('admin-inline-edit-form.tpl');
     if (!is_array($page_template_array)) {
         /* translators: 1: ERROR tag 2: function name 3: non-array value */
         error_log(sprintf(_x('%1$s: %2$s non-array "%3$s"', 'error_log', 'media-library-assistant'), __('ERROR', 'media-library-assistant'), 'MLA::_build_inline_edit_form', var_export($page_template_array, true)), 0);
         return '';
     }
     if ($authors = self::mla_authors_dropdown()) {
         $authors_dropdown = '              <label class="inline-edit-author">' . "\n";
         $authors_dropdown .= '                <span class="title">' . __('Author', 'media-library-assistant') . '</span>' . "\n";
         $authors_dropdown .= $authors . "\n";
         $authors_dropdown .= '              </label>' . "\n";
     } else {
         $authors_dropdown = '';
     }
     $custom_fields = '';
     foreach (MLAOptions::mla_custom_field_support('quick_edit') as $slug => $details) {
         $page_values = array('slug' => $slug, 'label' => esc_attr($details['name']));
         $custom_fields .= MLAData::mla_parse_template($page_template_array['custom_field'], $page_values);
     }
     /*
      * The middle column contains the hierarchical taxonomies, e.g., Attachment Category
      */
     $quick_middle_column = '';
     $bulk_middle_column = '';
     if (count($hierarchical_taxonomies)) {
         $quick_category_blocks = '';
         $bulk_category_blocks = '';
         foreach ($hierarchical_taxonomies as $tax_name => $tax_object) {
             if (current_user_can($tax_object->cap->assign_terms)) {
                 ob_start();
                 wp_terms_checklist(NULL, array('taxonomy' => $tax_name));
                 $tax_checklist = ob_get_contents();
                 ob_end_clean();
                 $page_values = array('tax_html' => esc_html($tax_object->labels->name), 'more' => __('more', 'media-library-assistant'), 'less' => __('less', 'media-library-assistant'), 'tax_attr' => esc_attr($tax_name), 'tax_checklist' => $tax_checklist, 'Add' => __('Add', 'media-library-assistant'), 'Remove' => __('Remove', 'media-library-assistant'), 'Replace' => __('Replace', 'media-library-assistant'));
                 $category_block = MLAData::mla_parse_template($page_template_array['category_block'], $page_values);
                 $taxonomy_options = MLAData::mla_parse_template($page_template_array['taxonomy_options'], $page_values);
                 $quick_category_blocks .= $category_block;
                 $bulk_category_blocks .= $category_block . $taxonomy_options;
             }
             // current_user_can
         }
         // foreach $hierarchical_taxonomies
         $page_values = array('category_blocks' => $quick_category_blocks);
         $quick_middle_column = MLAData::mla_parse_template($page_template_array['category_fieldset'], $page_values);
         $page_values = array('category_blocks' => $bulk_category_blocks);
         $bulk_middle_column = MLAData::mla_parse_template($page_template_array['category_fieldset'], $page_values);
     }
     // count( $hierarchical_taxonomies )
     /*
      * The right-hand column contains the flat taxonomies, e.g., Attachment Tag
      */
     $quick_right_column = '';
     $bulk_right_column = '';
     if (count($flat_taxonomies)) {
         $quick_tag_blocks = '';
         $bulk_tag_blocks = '';
         foreach ($flat_taxonomies as $tax_name => $tax_object) {
             if (current_user_can($tax_object->cap->assign_terms)) {
                 $page_values = array('tax_html' => esc_html($tax_object->labels->name), 'tax_attr' => esc_attr($tax_name), 'Add' => __('Add', 'media-library-assistant'), 'Remove' => __('Remove', 'media-library-assistant'), 'Replace' => __('Replace', 'media-library-assistant'));
                 $tag_block = MLAData::mla_parse_template($page_template_array['tag_block'], $page_values);
                 $taxonomy_options = MLAData::mla_parse_template($page_template_array['taxonomy_options'], $page_values);
                 $quick_tag_blocks .= $tag_block;
                 $bulk_tag_blocks .= $tag_block . $taxonomy_options;
             }
             // current_user_can
         }
         // foreach $flat_taxonomies
         $page_values = array('tag_blocks' => $quick_tag_blocks);
         $quick_right_column = MLAData::mla_parse_template($page_template_array['tag_fieldset'], $page_values);
         $page_values = array('tag_blocks' => $bulk_tag_blocks);
         $bulk_right_column = MLAData::mla_parse_template($page_template_array['tag_fieldset'], $page_values);
     }
     // count( $flat_taxonomies )
     if ($authors = self::mla_authors_dropdown(-1)) {
         $bulk_authors_dropdown = '              <label class="inline-edit-author alignright">' . "\n";
         $bulk_authors_dropdown .= '                <span class="title">' . __('Author', 'media-library-assistant') . '</span>' . "\n";
         $bulk_authors_dropdown .= $authors . "\n";
         $bulk_authors_dropdown .= '              </label>' . "\n";
     } else {
         $bulk_authors_dropdown = '';
     }
     $bulk_custom_fields = '';
     foreach (MLAOptions::mla_custom_field_support('bulk_edit') as $slug => $details) {
         $page_values = array('slug' => $slug, 'label' => esc_attr($details['name']));
         $bulk_custom_fields .= MLAData::mla_parse_template($page_template_array['custom_field'], $page_values);
     }
     $set_parent_form = MLA::mla_set_parent_form();
     $page_values = array('colspan' => $MLAListTable->get_column_count(), 'Quick Edit' => __('Quick Edit', 'media-library-assistant'), 'Title' => __('Title', 'media-library-assistant'), 'Name/Slug' => __('Name/Slug', 'media-library-assistant'), 'Caption' => __('Caption', 'media-library-assistant'), 'Description' => __('Description', 'media-library-assistant'), 'ALT Text' => __('ALT Text', 'media-library-assistant'), 'Parent ID' => __('Parent ID', 'media-library-assistant'), 'Select' => __('Select', 'media-library-assistant'), 'Menu Order' => __('Menu Order', 'media-library-assistant'), 'authors' => $authors_dropdown, 'custom_fields' => $custom_fields, 'quick_middle_column' => $quick_middle_column, 'quick_right_column' => $quick_right_column, 'Cancel' => __('Cancel', 'media-library-assistant'), 'Reset' => __('Reset', 'media-library-assistant'), 'Update' => __('Update', 'media-library-assistant'), 'Bulk Edit' => __('Bulk Edit', 'media-library-assistant'), 'bulk_middle_column' => $bulk_middle_column, 'bulk_right_column' => $bulk_right_column, 'bulk_authors' => $bulk_authors_dropdown, 'Comments' => __('Comments', 'media-library-assistant'), 'Pings' => __('Pings', 'media-library-assistant'), 'No Change' => __('No Change', 'media-library-assistant'), 'Allow' => __('Allow', 'media-library-assistant'), 'Do not allow' => __('Do not allow', 'media-library-assistant'), 'bulk_custom_fields' => $bulk_custom_fields, 'Map IPTC/EXIF metadata' => __('Map IPTC/EXIF metadata', 'media-library-assistant'), 'Map Custom Field metadata' => __('Map Custom Field metadata', 'media-library-assistant'), 'Bulk Waiting' => __('Waiting', 'media-library-assistant'), 'Bulk Running' => __('In-process', 'media-library-assistant'), 'Bulk Complete' => __('Complete', 'media-library-assistant'), 'Refresh' => __('Refresh', 'media-library-assistant'), 'set_parent_form' => $set_parent_form);
     $page_values = apply_filters('mla_list_table_inline_values', $page_values);
     $page_template = apply_filters('mla_list_table_inline_template', $page_template_array['page']);
     $parse_value = MLAData::mla_parse_template($page_template, $page_values);
     return apply_filters('mla_list_table_inline_parse', $parse_value, $page_template, $page_values);
 }
コード例 #5
0
 /**
  * Add contextual help tabs to the WordPress Edit Media page
  *
  * @since 0.90
  *
  * @param	string	title as shown on the screen
  * @param	string	title as shown in the HTML header
  *
  * @return	void
  */
 public static function mla_edit_add_help_tab($admin_title, $title)
 {
     $screen = get_current_screen();
     /*
      * Upload New Media Bulk Edit Area
      */
     if ('media' == $screen->id && 'add' == $screen->action) {
         $template_array = MLAData::mla_load_template('help-for-upload-new-media.tpl');
         if (empty($template_array)) {
             return $admin_title;
         }
         /*
          * Replace sidebar content
          */
         if (!empty($template_array['sidebar'])) {
             $page_values = array('settingsURL' => admin_url('options-general.php'));
             $content = MLAData::mla_parse_template($template_array['sidebar'], $page_values);
             $screen->set_help_sidebar($content);
         }
         unset($template_array['sidebar']);
         /*
          * Provide explicit control over tab order
          */
         $tab_array = array();
         foreach ($template_array as $id => $content) {
             $match_count = preg_match('#\\<!-- title="(.+)" order="(.+)" --\\>#', $content, $matches, PREG_OFFSET_CAPTURE);
             if ($match_count > 0) {
                 $tab_array[$matches[2][0]] = array('id' => $id, 'title' => $matches[1][0], 'content' => $content);
             } else {
                 /* translators: 1: ERROR tag 2: function name 3: template key */
                 error_log(sprintf(_x('%1$s: %2$s discarding "%3$s"; no title/order', 'error_log', 'media-library-assistant'), __('ERROR', 'media-library-assistant'), 'mla_edit_add_help_tab', $id), 0);
             }
         }
         ksort($tab_array, SORT_NUMERIC);
         foreach ($tab_array as $indx => $value) {
             $screen->add_help_tab($value);
         }
         return $admin_title;
     }
     /*
      * Media/Edit Media submenu
      */
     if ('attachment' != $screen->id || 'attachment' != $screen->post_type || 'post' != $screen->base) {
         return $admin_title;
     }
     $template_array = MLAData::mla_load_template('help-for-edit_attachment.tpl');
     if (empty($template_array)) {
         return $admin_title;
     }
     /*
      * Provide explicit control over tab order
      */
     $tab_array = array();
     foreach ($template_array as $id => $content) {
         $match_count = preg_match('#\\<!-- title="(.+)" order="(.+)" --\\>#', $content, $matches, PREG_OFFSET_CAPTURE);
         if ($match_count > 0) {
             $tab_array[$matches[2][0]] = array('id' => $id, 'title' => $matches[1][0], 'content' => $content);
         } else {
             /* translators: 1: ERROR tag 2: function name 3: template key */
             error_log(sprintf(_x('%1$s: %2$s discarding "%3$s"; no title/order', 'error_log', 'media-library-assistant'), __('ERROR', 'media-library-assistant'), 'mla_edit_add_help_tab', $id), 0);
         }
     }
     ksort($tab_array, SORT_NUMERIC);
     foreach ($tab_array as $indx => $value) {
         $screen->add_help_tab($value);
     }
     return $admin_title;
 }
コード例 #6
0
 /**
  * MLA_List_Table inline edit parse
  *
  * @since 2.13
  *
  * Adds Bulk Translate form and the Language dropdown
  * markup used for the Quick and Bulk Edit forms.
  *
  * @param	string	HTML markup returned by the template parser
  * @param	string	template used to generate the HTML markup
  * @param	array	parameter_name => parameter_value pairs
  *
  * @return	array	updated HTML markup for the Quick and Bulk Edit forms
  */
 public static function mla_list_table_inline_parse($html_markup, $item_template, $item_values)
 {
     /*
      * Add the Thumbnail Generation Markup
      */
     $page_template_array = MLAData::mla_load_template('mla-thumbnail-generation.tpl');
     if (!is_array($page_template_array)) {
         error_log('ERROR: mla-thumbnail-generation.tpl path = ' . var_export(plugin_dir_path(__FILE__) . 'mla-thumbnail-generation.tpl', true), 0);
         error_log('ERROR: mla-thumbnail-generation.tpl non-array result = ' . var_export($page_template_array, true), 0);
         return $html_markup;
     }
     $page_values = array('colspan' => $item_values['colspan'], 'Generate Thumbnails' => __('Generate Thumbnails', 'media-library-assistant'), 'See Documentation' => __('Pull down the Help menu and select Thumbnail Generation for setting details', 'media-library-assistant'), 'Width' => __('Width', 'media-library-assistant'), 'Height' => __('Height', 'media-library-assistant'), 'Best Fit' => __('Best Fit', 'media-library-assistant'), 'Page' => __('Page', 'media-library-assistant'), 'Resolution' => __('Resolution', 'media-library-assistant'), 'Quality' => __('Quality', 'media-library-assistant'), 'Type' => __('Type', 'media-library-assistant'), 'Existing Items' => __('Existing Items', 'media-library-assistant'), 'Keep' => __('Keep', 'media-library-assistant'), 'Ignore' => __('Ignore', 'media-library-assistant'), 'Trash' => __('Trash', 'media-library-assistant'), 'Delete' => __('Delete', 'media-library-assistant'), 'Suffix' => __('Suffix', 'media-library-assistant'), 'default_suffix' => '-' . __('Thumbnail', 'media-library-assistant'), 'Options' => __('Options', 'media-library-assistant'), 'Clear Filter-by' => __('Clear Filter-by', 'media-library-assistant'), 'Cancel' => __('Cancel', 'media-library-assistant'));
     $parse_value = MLAData::mla_parse_template($page_template_array['page'], $page_values);
     return $html_markup . "\n" . $parse_value;
 }
コード例 #7
0
 /**
  * Add contextual help tabs to the WordPress Edit Media page
  *
  * @since 0.90
  *
  * @param	string	title as shown on the screen
  * @param	string	title as shown in the HTML header
  *
  * @return	void
  */
 public static function mla_edit_add_help_tab($admin_title, $title)
 {
     $screen = get_current_screen();
     if ('attachment' != $screen->id || 'attachment' != $screen->post_type || 'post' != $screen->base) {
         return $admin_title;
     }
     $template_array = MLAData::mla_load_template(MLA_PLUGIN_PATH . 'tpls/help-for-edit_attachment.tpl');
     if (empty($template_array)) {
         return $admin_title;
     }
     /*
      * Provide explicit control over tab order
      */
     $tab_array = array();
     foreach ($template_array as $id => $content) {
         $match_count = preg_match('#\\<!-- title="(.+)" order="(.+)" --\\>#', $content, $matches, PREG_OFFSET_CAPTURE);
         if ($match_count > 0) {
             $tab_array[$matches[2][0]] = array('id' => $id, 'title' => $matches[1][0], 'content' => $content);
         } else {
             error_log('ERROR: mla_edit_add_help_tab discarding ' . var_export($id, true), 0);
         }
     }
     ksort($tab_array, SORT_NUMERIC);
     foreach ($tab_array as $indx => $value) {
         $screen->add_help_tab($value);
     }
     return $admin_title;
 }
コード例 #8
0
 /**
  * Build the hidden form for the "Search Terms" popup modal window
  *
  * @since 1.90
  *
  * @return	string	HTML <form> markup for hidden form
  */
 public static function mla_terms_search_form()
 {
     $page_template_array = MLAData::mla_load_template('admin-terms-search-form.tpl');
     if (!is_array($page_template_array)) {
         /* translators: 1: ERROR tag 2: function name 3: non-array value */
         error_log(sprintf(_x('%1$s: %2$s non-array "%3$s"', 'error_log', 'media-library-assistant'), __('ERROR', 'media-library-assistant'), 'MLA::_build_terms_search_form', var_export($page_template_array, true)), 0);
         return '';
     }
     $taxonomies = array();
     foreach (get_object_taxonomies('attachment', 'objects') as $taxonomy) {
         if (MLAOptions::mla_taxonomy_support($taxonomy->name, 'support')) {
             $taxonomies[] = $taxonomy;
         }
     }
     if (empty($taxonomies)) {
         $page_values = array('Search Terms' => __('Search Terms', 'media-library-assistant'), 'message' => __('There are no taxonomies to search', 'media-library-assistant'));
         $terms_search_tpl = MLAData::mla_parse_template($page_template_array['mla-terms-search-empty-div'], $page_values);
     } else {
         $taxonomy_list = '';
         foreach ($taxonomies as $taxonomy) {
             $page_values = array('taxonomy_checked' => MLAOptions::mla_taxonomy_support($taxonomy->name, 'term-search') ? 'checked="checked"' : '', 'taxonomy_slug' => $taxonomy->name, 'taxonomy_label' => esc_attr($taxonomy->label));
             $taxonomy_list .= MLAData::mla_parse_template($page_template_array['mla-terms-search-taxonomy'], $page_values);
         }
         $page_values = array('Search Terms' => __('Search Terms', 'media-library-assistant'), 'Search' => __('Search', 'media-library-assistant'), 'phrases_and_checked' => 'checked="checked"', 'All phrases' => __('All phrases', 'media-library-assistant'), 'phrases_or_checked' => '', 'Any phrase' => __('Any phrase', 'media-library-assistant'), 'terms_and_checked' => '', 'All terms' => __('All terms', 'media-library-assistant'), 'terms_or_checked' => 'checked="checked"', 'Any term' => __('Any term', 'media-library-assistant'), 'exact_checked' => '', 'Exact' => __('Exact', 'media-library-assistant'), 'mla_terms_search_taxonomies' => $taxonomy_list);
         $terms_search_tpl = MLAData::mla_parse_template($page_template_array['mla-terms-search-div'], $page_values);
     }
     $page_values = array('mla_terms_search_url' => esc_url(add_query_arg(array_merge(MLA_List_Table::mla_submenu_arguments(false), array('page' => MLA::ADMIN_PAGE_SLUG)), admin_url('upload.php'))), 'mla_terms_search_action' => MLA::MLA_ADMIN_TERMS_SEARCH, 'wpnonce' => wp_nonce_field(MLA::MLA_ADMIN_NONCE_ACTION, MLA::MLA_ADMIN_NONCE_NAME, true, false), 'mla_terms_search_div' => $terms_search_tpl);
     $terms_search_tpl = MLAData::mla_parse_template($page_template_array['mla-terms-search-form'], $page_values);
     return $terms_search_tpl;
 }
コード例 #9
0
 /**
  * Load style and markup templates to $mla_templates
  *
  * @since 0.80
  *
  * @return	void
  */
 private static function _load_option_templates()
 {
     MLAOptions::$mla_option_templates = MLAData::mla_load_template('mla-option-templates.tpl');
     /* 	
      * Load the default templates
      */
     if (is_null(MLAOptions::$mla_option_templates)) {
         MLACore::mla_debug_add('<strong>mla_debug _load_option_templates()</strong> ' . __('error loading tpls/mla-option-templates.tpl', 'media-library-assistant'));
         return;
     } elseif (!MLAOptions::$mla_option_templates) {
         MLACore::mla_debug_add('<strong>mla_debug _load_option_templates()</strong> ' . __('tpls/mla-option-templates.tpl not found', 'media-library-assistant'));
         MLAOptions::$mla_option_templates = NULL;
         return;
     }
 }
コード例 #10
0
 /**
  * Display a single item sub page; prepare the form to 
  * change the meta data for a single attachment.
  * 
  * This function is not used in WordPress 3.5 and later.
  *
  * @since 0.1
  * 
  * @param	int		The WordPress Post ID of the attachment item
  *
  * @return	array	message and/or HTML content
  */
 private static function _display_single_item($post_id)
 {
     global $post;
     /*
      * This function sets the global $post
      */
     $post_data = MLAData::mla_get_attachment_by_id($post_id);
     if (!isset($post_data)) {
         return array('message' => 'ERROR: Could not retrieve Attachment.', 'body' => '');
     }
     if (!current_user_can('edit_post', $post_id)) {
         return array('message' => 'You are not allowed to edit this Attachment.', 'body' => '');
     }
     if (!empty($post_data['mla_wp_attachment_metadata'])) {
         $page_template_array = MLAData::mla_load_template(MLA_PLUGIN_PATH . 'tpls/admin-display-single-image.tpl');
         $width = isset($post_data['mla_wp_attachment_metadata']['width']) ? $post_data['mla_wp_attachment_metadata']['width'] : '';
         $height = isset($post_data['mla_wp_attachment_metadata']['height']) ? $post_data['mla_wp_attachment_metadata']['height'] : '';
         $image_meta = var_export($post_data['mla_wp_attachment_metadata'], true);
         if (!isset($post_data['mla_wp_attachment_image_alt'])) {
             $post_data['mla_wp_attachment_image_alt'] = '';
         }
     } else {
         $page_template_array = MLAData::mla_load_template(MLA_PLUGIN_PATH . 'tpls/admin-display-single-document.tpl');
         $width = '';
         $height = '';
         $image_meta = '';
     }
     if (array($page_template_array)) {
         $page_template = $page_template_array['page'];
         $authors_template = $page_template_array['authors'];
         $postbox_template = $page_template_array['postbox'];
     } else {
         error_log("ERROR: MLA::_display_single_item \$page_template_array = " . var_export($page_template_array, true), 0);
         $page_template = $page_template_array;
         $authors_template = '';
         $postbox_template = '';
     }
     if (empty($post_data['mla_references']['parent_title'])) {
         $parent_info = $post_data['mla_references']['parent_errors'];
     } else {
         $parent_info = sprintf('(%1$s) %2$s %3$s', $post_data['mla_references']['parent_type'], $post_data['mla_references']['parent_title'], $post_data['mla_references']['parent_errors']);
     }
     if ($authors = self::_authors_dropdown($post_data['post_author'], 'attachments[' . $post_data['ID'] . '][post_author]')) {
         $args = array('ID' => $post_data['ID'], 'authors' => $authors);
         $authors = MLAData::mla_parse_template($authors_template, $args);
     } else {
         $authors = '';
     }
     if (MLAOptions::$process_featured_in) {
         $features = '';
         foreach ($post_data['mla_references']['features'] as $feature_id => $feature) {
             if ($feature_id == $post_data['post_parent']) {
                 $parent = 'PARENT ';
             } else {
                 $parent = '';
             }
             $features .= sprintf('%1$s (%2$s %3$s), %4$s', $parent, $feature->post_type, $feature_id, $feature->post_title) . "\r\n";
         }
         // foreach $feature
     } else {
         $features = 'disabled';
     }
     if (MLAOptions::$process_inserted_in) {
         $inserts = '';
         foreach ($post_data['mla_references']['inserts'] as $file => $insert_array) {
             $inserts .= $file . "\r\n";
             foreach ($insert_array as $insert) {
                 if ($insert->ID == $post_data['post_parent']) {
                     $parent = '  PARENT ';
                 } else {
                     $parent = '  ';
                 }
                 $inserts .= sprintf('%1$s (%2$s %3$s), %4$s', $parent, $insert->post_type, $insert->ID, $insert->post_title) . "\r\n";
             }
             // foreach $insert
         }
         // foreach $file
     } else {
         $inserts = 'disabled';
     }
     if (MLAOptions::$process_gallery_in) {
         $galleries = '';
         foreach ($post_data['mla_references']['galleries'] as $gallery_id => $gallery) {
             if ($gallery_id == $post_data['post_parent']) {
                 $parent = 'PARENT ';
             } else {
                 $parent = '';
             }
             $galleries .= sprintf('%1$s (%2$s %3$s), %4$s', $parent, $gallery['post_type'], $gallery_id, $gallery['post_title']) . "\r\n";
         }
         // foreach $gallery
     } else {
         $galleries = 'disabled';
     }
     if (MLAOptions::$process_mla_gallery_in) {
         $mla_galleries = '';
         foreach ($post_data['mla_references']['mla_galleries'] as $gallery_id => $gallery) {
             if ($gallery_id == $post_data['post_parent']) {
                 $parent = 'PARENT ';
             } else {
                 $parent = '';
             }
             $mla_galleries .= sprintf('%1$s (%2$s %3$s), %4$s', $parent, $gallery['post_type'], $gallery_id, $gallery['post_title']) . "\r\n";
         }
         // foreach $gallery
     } else {
         $mla_galleries = 'disabled';
     }
     /*
      * WordPress doesn't look in hidden fields to set the month filter dropdown or sorting parameters
      */
     if (isset($_REQUEST['m'])) {
         $url_args = '&m=' . $_REQUEST['m'];
     } else {
         $url_args = '';
     }
     if (isset($_REQUEST['post_mime_type'])) {
         $url_args .= '&post_mime_type=' . $_REQUEST['post_mime_type'];
     }
     if (isset($_REQUEST['order'])) {
         $url_args .= '&order=' . $_REQUEST['order'];
     }
     if (isset($_REQUEST['orderby'])) {
         $url_args .= '&orderby=' . $_REQUEST['orderby'];
     }
     /*
      * Add the current view arguments
      */
     if (isset($_REQUEST['detached'])) {
         $view_args = '<input type="hidden" name="detached" value="' . $_REQUEST['detached'] . "\" />\r\n";
     } elseif (isset($_REQUEST['status'])) {
         $view_args = '<input type="hidden" name="status" value="' . $_REQUEST['status'] . "\" />\r\n";
     } else {
         $view_args = '';
     }
     if (isset($_REQUEST['paged'])) {
         $view_args .= sprintf('<input type="hidden" name="paged" value="%1$s" />', $_REQUEST['paged']) . "\r\n";
     }
     $side_info_column = '';
     $taxonomies = get_object_taxonomies('attachment', 'objects');
     foreach ($taxonomies as $tax_name => $tax_object) {
         ob_start();
         if ($tax_object->hierarchical && $tax_object->show_ui) {
             $box = array('id' => $tax_name . 'div', 'title' => esc_html($tax_object->labels->name), 'callback' => 'categories_meta_box', 'args' => array('taxonomy' => $tax_name), 'inside_html' => '');
             post_categories_meta_box($post, $box);
         } elseif ($tax_object->show_ui) {
             $box = array('id' => 'tagsdiv-' . $tax_name, 'title' => esc_html($tax_object->labels->name), 'callback' => 'post_tags_meta_box', 'args' => array('taxonomy' => $tax_name), 'inside_html' => '');
             post_tags_meta_box($post, $box);
         }
         $box['inside_html'] = ob_get_contents();
         ob_end_clean();
         $side_info_column .= MLAData::mla_parse_template($postbox_template, $box);
     }
     $page_values = array('ID' => $post_data['ID'], 'post_mime_type' => $post_data['post_mime_type'], 'menu_order' => $post_data['menu_order'], 'post_date' => $post_data['post_date'], 'post_modified' => $post_data['post_modified'], 'post_parent' => $post_data['post_parent'], 'menu_order' => $post_data['menu_order'], 'attachment_icon' => wp_get_attachment_image($post_id, array(160, 120), true), 'file_name' => esc_html($post_data['mla_references']['file']), 'width' => $width, 'height' => $height, 'post_title_attr' => esc_attr($post_data['post_title']), 'post_name_attr' => esc_attr($post_data['post_name']), 'image_alt_attr' => '', 'post_excerpt_attr' => esc_attr($post_data['post_excerpt']), 'post_content' => esc_textarea($post_data['post_content']), 'image_meta' => esc_textarea($image_meta), 'parent_info' => esc_attr($parent_info), 'guid_attr' => esc_attr($post_data['guid']), 'authors' => $authors, 'features' => esc_textarea($features), 'inserts' => esc_textarea($inserts), 'galleries' => esc_textarea($galleries), 'mla_galleries' => esc_textarea($mla_galleries), 'mla_admin_action' => self::MLA_ADMIN_SINGLE_EDIT_UPDATE, 'form_url' => admin_url('upload.php') . '?page=' . self::ADMIN_PAGE_SLUG . $url_args, 'view_args' => $view_args, 'wpnonce' => wp_nonce_field(self::MLA_ADMIN_NONCE, '_wpnonce', true, false), 'side_info_column' => $side_info_column);
     if (!empty($post_data['mla_wp_attachment_image_alt'])) {
         $page_values['image_alt_attr'] = esc_attr($post_data['mla_wp_attachment_image_alt']);
     }
     return array('message' => '', 'body' => MLAData::mla_parse_template($page_template, $page_values));
 }
コード例 #11
0
 /**
  * Render (echo) the "Media Library Assistant" subpage in the Settings section
  *
  * @since 0.1
  *
  * @return	void Echoes HTML markup for the Settings subpage
  */
 public static function mla_render_settings_page()
 {
     if (!current_user_can('manage_options')) {
         echo __('Media Library Assistant', 'media-library-assistant') . ' - ' . __('ERROR', 'media-library-assistant') . "</h2>\r\n";
         wp_die(__('You do not have permission to manage plugin settings.', 'media-library-assistant'));
     }
     /*
      * Load template array and initialize page-level values.
      */
     $development_version = MLA::MLA_DEVELOPMENT_VERSION;
     $development_version = !empty($development_version) ? ' (' . $development_version . ')' : '';
     self::$page_template_array = MLAData::mla_load_template('admin-display-settings-page.tpl');
     $current_tab_slug = isset($_REQUEST['mla_tab']) ? $_REQUEST['mla_tab'] : 'general';
     $current_tab = self::mla_get_options_tablist($current_tab_slug);
     $page_values = array('Support Our Work' => __('Support Our Work', 'media-library-assistant'), 'Donate' => __('Donate', 'media-library-assistant'), 'version' => 'v' . MLA::CURRENT_MLA_VERSION, 'development' => $development_version, 'messages' => '', 'tablist' => self::_compose_settings_tabs($current_tab_slug), 'tab_content' => '', 'Media Library Assistant' => __('Media Library Assistant', 'media-library-assistant'), 'Settings' => __('Settings', 'media-library-assistant'));
     /*
      * Compose tab content
      */
     if ($current_tab) {
         if (isset($current_tab['render'])) {
             $handler = $current_tab['render'];
             $page_content = call_user_func($handler);
         } else {
             $page_content = array('message' => __('ERROR', 'media-library-assistant') . ': ' . __('Cannot render content tab', 'media-library-assistant'), 'body' => '');
         }
     } else {
         $page_content = array('message' => __('ERROR', 'media-library-assistant') . ': ' . __('Unknown content tab', 'media-library-assistant'), 'body' => '');
     }
     if (!empty($page_content['message'])) {
         if (false !== strpos($page_content['message'], __('ERROR', 'media-library-assistant'))) {
             $messages_class = 'mla_errors';
         } else {
             $messages_class = 'mla_messages';
         }
         $page_values['messages'] = MLAData::mla_parse_template(self::$page_template_array['messages'], array('messages' => $page_content['message'], 'mla_messages_class' => $messages_class));
     }
     $page_values['tab_content'] = $page_content['body'];
     echo MLAData::mla_parse_template(self::$page_template_array['page'], $page_values);
 }
コード例 #12
0
 /**
  * Render (echo) the "Media Library Assistant" subpage in the Settings section
  *
  * @since 0.1
  *
  * @return	void Echoes HTML markup for the Settings subpage
  */
 public static function mla_render_settings_page()
 {
     if (!current_user_can('manage_options')) {
         echo "Media Library Assistant - Error</h2>\r\n";
         wp_die(__('You do not have permission to manage plugin settings.'));
     }
     /*
      * Load template array and initialize page-level values.
      */
     self::$page_template_array = MLAData::mla_load_template(MLA_PLUGIN_PATH . 'tpls/admin-display-settings-page.tpl');
     $current_tab = isset($_REQUEST['mla_tab']) ? $_REQUEST['mla_tab'] : 'general';
     $page_values = array('settingsURL' => admin_url('options-general.php'), 'version' => 'v' . MLA::CURRENT_MLA_VERSION, 'donateURL' => MLA_PLUGIN_URL . 'images/DonateButton.jpg', 'messages' => '', 'tablist' => self::_compose_settings_tabs($current_tab), 'tab_content' => '');
     /*
      * Compose tab content
      */
     if (array_key_exists($current_tab, self::$mla_tablist)) {
         if (isset(self::$mla_tablist[$current_tab]['render'])) {
             $handler = self::$mla_tablist[$current_tab]['render'];
             $page_content = self::$handler();
         } else {
             $page_content = array('message' => 'ERROR: cannot render content tab', 'body' => '');
         }
     } else {
         $page_content = array('message' => 'ERROR: unknown content tab', 'body' => '');
     }
     if (!empty($page_content['message'])) {
         if (false !== strpos($page_content['message'], 'ERROR:')) {
             $messages_class = 'mla_errors';
         } else {
             $messages_class = 'mla_messages';
         }
         $page_values['messages'] = MLAData::mla_parse_template(self::$page_template_array['messages'], array('messages' => $page_content['message'], 'mla_messages_class' => $messages_class));
     }
     $page_values['tab_content'] = $page_content['body'];
     echo MLAData::mla_parse_template(self::$page_template_array['page'], $page_values);
 }
コード例 #13
0
 /**
  * Load style and markup templates to $mla_templates
  *
  * @since 0.80
  *
  * @return	void
  */
 private static function _load_option_templates()
 {
     self::$mla_option_templates = MLAData::mla_load_template(MLA_PLUGIN_PATH . 'tpls/mla-option-templates.tpl');
     /* 	
      * Load the default templates
      */
     if (is_null(self::$mla_option_templates)) {
         MLAShortcodes::$mla_debug_messages .= '<p><strong>_load_option_templates()</strong> error loading tpls/mla-option-templates.tpl';
         return;
     } elseif (!self::$mla_option_templates) {
         MLAShortcodes::$mla_debug_messages .= '<p><strong>_load_option_templates()</strong>tpls/mla-option-templates.tpl not found';
         $mla_option_templates = null;
         return;
     }
     /*
      * Add user-defined Style and Markup templates
      */
     $templates = self::mla_get_option('style_templates');
     if (is_array($templates)) {
         foreach ($templates as $name => $value) {
             self::$mla_option_templates[$name . '-style'] = $value;
         }
         // foreach $templates
     }
     // is_array
     $templates = self::mla_get_option('markup_templates');
     if (is_array($templates)) {
         foreach ($templates as $name => $value) {
             self::$mla_option_templates[$name . '-open-markup'] = $value['open'];
             self::$mla_option_templates[$name . '-row-open-markup'] = $value['row-open'];
             self::$mla_option_templates[$name . '-item-markup'] = $value['item'];
             self::$mla_option_templates[$name . '-row-close-markup'] = $value['row-close'];
             self::$mla_option_templates[$name . '-close-markup'] = $value['close'];
         }
         // foreach $templates
     }
     // is_array
 }