Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From b74d96ec7dab9ca8ad7faabd9e77a1dd722674e2 Mon Sep 17 00:00:00 2001
- From: Hari Karam Singh <harikaram@regallygraceful.com>
- Date: Mon, 28 Nov 2011 12:35:32 +0000
- Subject: [PATCH] Fixed bogus on/off setting and added auto-tag slug suffix to
- prevent conflicts with post tags etc
- ---
- mediatags_admin.php | 13 ++++++++++---
- mediatags_settings.php | 13 ++++++++++++-
- 2 files changed, 22 insertions(+), 4 deletions(-)
- diff --git a/mediatags_admin.php b/mediatags_admin.php
- index 0d97eb6..37cb00c 100755
- --- a/mediatags_admin.php
- +++ b/mediatags_admin.php
- @@ -1059,7 +1059,7 @@ function mediatags_autotag_from_iptc_keywords( $meta_id, $attachment_id, $meta_k
- // Check that it's an upload and that our setting is on
- // Do the action when _wp_attachment_metadata is first added in order to catch each attachment
- if ( !$_POST['Upload'] || $meta_key != '_wp_attachment_metadata' ) return;
- - if ( 'yes' !== get_option( 'mediatags_autotag_from_iptc_keywords', 'yes' ) ) return;
- + if ( 'yes' !== get_option( 'mediatag_autotag_on_upload', 'no' ) ) return;
- // GRAB THE TAGS FROM THE IPTC KEYWORDS
- // First get the supported image types
- @@ -1087,10 +1087,17 @@ function mediatags_autotag_from_iptc_keywords( $meta_id, $attachment_id, $meta_k
- $media_tags_array = array();
- if ($keywords) {
- foreach($keywords as $tag) {
- - $tag_slug = sanitize_title_with_dashes($tag);
- +
- + // Append suffix if specified
- + $tag_slug = $tag;
- + if ($slug_suffix = get_option('mediatag_autotag_slug_suffix')) {
- + $tag_slug .= $slug_suffix;
- + }
- + // Clean up afterwards in case of a dodgy setting
- + $tag_slug = sanitize_title_with_dashes($tag_slug);
- if ( ! ($id = term_exists( $tag_slug, MEDIA_TAGS_TAXONOMY ) ) )
- - wp_insert_term($tag_val, MEDIA_TAGS_TAXONOMY, array('slug' => $tag_slug));
- + wp_insert_term($tag, MEDIA_TAGS_TAXONOMY, array('slug' => $tag_slug));
- $media_tags_array[] = $tag_slug;
- }
- diff --git a/mediatags_settings.php b/mediatags_settings.php
- index 3ff64e2..728b47d 100755
- --- a/mediatags_settings.php
- +++ b/mediatags_settings.php
- @@ -133,6 +133,11 @@ function mediatags_settings_panel()
- update_option( 'mediatag_autotag_on_upload', $mediatag_autotag_on_upload );
- $update_message = _x("Media-Tags Settings have been updated.", 'update message', MEDIA_TAGS_I18N_DOMAIN);
- }
- + if (isset($_REQUEST['mediatag_autotag_slug_suffix']))
- + {
- + update_option( 'mediatag_autotag_slug_suffix', $_REQUEST['mediatag_autotag_slug_suffix'] );
- + $update_message = _x("Media-Tags Settings have been updated.", 'update message', MEDIA_TAGS_I18N_DOMAIN);
- + }
- }
- $title = _x('Media-Tags Settings', 'settings panel title', MEDIA_TAGS_I18N_DOMAIN);
- ?>
- @@ -222,7 +227,8 @@ function mediatags_settings_panel()
- mediatag_settings_boxheader('mediatag-options-auto-tagging',
- __('Auto-Tag Settings for Uploaded Media', MEDIA_TAGS_I18N_DOMAIN));
- - $mediatag_autotag_on_upload = get_option('mediatag_autotag_on_upload', 'yes');?>
- + $mediatag_autotag_on_upload = get_option('mediatag_autotag_on_upload', 'yes');
- + $mediatag_autotag_slug_suffix = get_option('mediatag_autotag_slug_suffix', '-media');?>
- <p><?php _e("Media-Tags can extract the IPTC keywords for media files and auto-save them to newly uploaded media.", MEDIA_TAGS_I18N_DOMAIN); ?></p>
- @@ -234,6 +240,11 @@ function mediatags_settings_panel()
- </select>
- <label for="mediatag_autotag_on_upload"><?php _e('Turn Auto-Tagging of Uploaded Files On/Off',
- MEDIA_TAGS_I18N_DOMAIN); ?></label>
- +
- + <p>
- + <label for="mediatag_autotag_slug_suffix"><?php _e('Append this suffix onto slugs to prevent conflicts with other taxonomies',
- + MEDIA_TAGS_I18N_DOMAIN); ?></label><br/>
- + <input type="text" id="mediatag_autotag_slug_suffix" name="mediatag_autotag_slug_suffix" value="<?php esc_attr_e($mediatag_autotag_slug_suffix)?>"></p>
- <?php mediatag_settings_boxfooter(false); ?>
- --
- 1.7.5.1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement