├── languages ├── globalsitetags-en_US.mo └── globalsitetags-en_US.po ├── .gitmodules ├── changelog.txt ├── README.md ├── widget-global-site-tags.php └── global-site-tags.php /languages/globalsitetags-en_US.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wpmudev/global-site-tags/master/languages/globalsitetags-en_US.mo -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "dash-notice"] 2 | path = dash-notice 3 | url = git@bitbucket.org:incsub/wpmudev-dashboard-notification.git 4 | branch = master 5 | -------------------------------------------------------------------------------- /changelog.txt: -------------------------------------------------------------------------------- 1 | == 3.1.0.1 == 2 | * Corrected error where widget PHP file was being loaded twice 3 | * Added graceful check to widget if main global site tags plugin was deactivated. 4 | -------------------------------------------------------------------------------- /languages/globalsitetags-en_US.po: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "Project-Id-Version: Global Site Tags 2.0\n" 4 | "Report-Msgid-Bugs-To: \n" 5 | "POT-Creation-Date: 2014-01-13 18:14+0300\n" 6 | "PO-Revision-Date: 2014-01-13 18:14+0300\n" 7 | "Last-Translator: Eugene Manuilov \n" 8 | "Language-Team: Incsub \n" 9 | "Language: en_US\n" 10 | "MIME-Version: 1.0\n" 11 | "Content-Type: text/plain; charset=UTF-8\n" 12 | "Content-Transfer-Encoding: 8bit\n" 13 | "Plural-Forms: nplurals=2; plural=n != 1;\n" 14 | "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;" 15 | "_n_noop:1,2;_c;_nc:4c,1,2;_x:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;_ex:1,2c;" 16 | "esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;" 17 | "_n_noop;_nc;_nx;_nx_noop\n" 18 | "X-Poedit-Basepath: .\n" 19 | "X-Generator: Poedit 1.5.4\n" 20 | "X-Poedit-SourceCharset: UTF-8\n" 21 | "X-Poedit-SearchPath-0: ./..\n" 22 | 23 | #: ../widget-global-site-tags.php:14 24 | msgid "Global Site Tags" 25 | msgstr "Global Site Tags" 26 | 27 | #: ../widget-global-site-tags.php:15 28 | msgid "Displays tags from all blogs" 29 | msgstr "Displays tags from all blogs" 30 | 31 | #: ../widget-global-site-tags.php:29 ../global-site-tags.php:124 32 | msgid "Tags" 33 | msgstr "Tags" 34 | 35 | #: ../widget-global-site-tags.php:69 36 | msgid "Widget Title" 37 | msgstr "Widget Title" 38 | 39 | #: ../widget-global-site-tags.php:74 40 | msgid "Number of Tags" 41 | msgstr "Number of Tags" 42 | 43 | #: ../widget-global-site-tags.php:83 44 | msgid "Largest Font Size" 45 | msgstr "Largest Font Size" 46 | 47 | #: ../widget-global-site-tags.php:92 48 | msgid "Smallest Font Size" 49 | msgstr "Smallest Font Size" 50 | 51 | #: ../widget-global-site-tags.php:101 52 | msgid "Post Type" 53 | msgstr "Post Type" 54 | 55 | #: ../widget-global-site-tags.php:103 ../global-site-tags.php:214 56 | msgid "all" 57 | msgstr "all" 58 | 59 | #: ../widget-global-site-tags.php:109 60 | msgid "post" 61 | msgstr "post" 62 | 63 | #: ../global-site-tags.php:159 64 | msgid "Site Tags" 65 | msgstr "Site Tags" 66 | 67 | #: ../global-site-tags.php:163 68 | msgid "Tags Shown" 69 | msgstr "Tags Shown" 70 | 71 | #: ../global-site-tags.php:173 72 | msgid "Listing Per Page" 73 | msgstr "Listing Per Page" 74 | 75 | #: ../global-site-tags.php:183 76 | msgid "Background Color" 77 | msgstr "Background Color" 78 | 79 | #: ../global-site-tags.php:186 ../global-site-tags.php:193 80 | #: ../global-site-tags.php:200 81 | msgid "Default" 82 | msgstr "Default" 83 | 84 | #: ../global-site-tags.php:190 85 | msgid "Alternate Background Color" 86 | msgstr "Alternate Background Color" 87 | 88 | #: ../global-site-tags.php:197 89 | msgid "Border Color" 90 | msgstr "Border Color" 91 | 92 | #: ../global-site-tags.php:204 93 | msgid "Banned Tags" 94 | msgstr "Banned Tags" 95 | 96 | #: ../global-site-tags.php:207 97 | msgid "" 98 | "Banned tags will not appear in tag clouds. Please separate tags with commas. " 99 | "Ex: tag1, tag2, tag3" 100 | msgstr "" 101 | "Banned tags will not appear in tag clouds. Please separate tags with commas. " 102 | "Ex: tag1, tag2, tag3" 103 | 104 | #: ../global-site-tags.php:211 105 | msgid "List Post Type" 106 | msgstr "List Post Type" 107 | 108 | #: ../global-site-tags.php:291 109 | msgid "There are no tags to display." 110 | msgstr "There are no tags to display." 111 | 112 | #: ../global-site-tags.php:350 113 | msgid "Nothing found for search term(s)." 114 | msgstr "Nothing found for search term(s)." 115 | 116 | #: ../global-site-tags.php:368 117 | msgid "Posts" 118 | msgstr "Posts" 119 | 120 | #: ../global-site-tags.php:383 121 | msgid "Unknown" 122 | msgstr "Unknown" 123 | 124 | #: ../global-site-tags.php:394 125 | msgid " wrote" 126 | msgstr " wrote" 127 | 128 | #: ../global-site-tags.php:395 129 | #, php-format 130 | msgctxt "{author name} wrote" 131 | msgid "%s wrote" 132 | msgstr "%s wrote" 133 | 134 | #: ../global-site-tags.php:397 135 | msgid "More" 136 | msgstr "More" 137 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Global Site Tags 2 | 3 | **INACTIVE NOTICE: This plugin is unsupported by WPMUDEV, we've published it here for those technical types who might want to fork and maintain it for their needs.** 4 | 5 | ## Translations 6 | 7 | Translation files can be found at https://github.com/wpmudev/translations 8 | 9 | ## About 10 | 11 | Global Site Tags pulls together the most popular tags from across a Multisite network to generate a tag cloud. 12 | 13 | Discover new authors, finding new content and following trends. Provide a visually interesting element to your site and increase function and usability with a cloud list. Engage readers with a list that scales font-size to reflect use and popularity. 14 | 15 | ![Linked tag list for simple navigation.](http://premium.wpmudev.org/wp-content/uploads/2009/09/tag-cloud.jpg) 16 | 17 | Linked tag list for simple navigation. 18 | 19 | ### Automated setup and management 20 | 21 | When activated a tags page displaying your new global cloud is added to your main site. As trends shift, or new tags are added, the list instantly updates across your entire network. Click on a tag and display an ordered list of posts that includes the authors avatar. Paginate settings make for a clean, simple search experience. 22 | 23 | ![Help readers discover interesting content.](http://premium.wpmudev.org/wp-content/uploads/2009/09/list.jpg) 24 | 25 | Help readers discover interesting content. 26 | 27 | ### Designed to style-match 28 | 29 | Global Site Tags is designed to use your theme’s stylesheet allowing each element to appear native to your site. For fine-tune control, a settings panel is added to network settings. Set the number of tags you want to display, how many posts are listed when a tag is clicked and a custom color palette. Share a global site tag list across your entire network using the built-in widget. Configure to display uniquely for each widget area. Add a fun, interesting way for users to discover even more blogs, content and authors across your Multisite network. 30 | 31 | ## Usage 32 | 33 | Before starting this install you must be sure that you have the [Post Indexer](https://premium.wpmudev.org/project/post-indexer "Post") plugin installed For help with installing plugins please see our [Plugin installation guide](https://premium.wpmudev.org/wpmu-manual/installing-regular-plugins-on-wpmu/) _*NOTE: This plugin is for Multisite installs only, it will not work on your Single Install_ Once installed login into your Network Admin Dashboard and activate the plugin by going to visit **Network Admin -> Plugins** and Network Activate the Global Site Tags plugin. 34 | 35 | ### To use: 36 | 37 | It should auto create a page called \"tags\" on your main blog where anyone can search through all your blogs. 38 | 39 | ![Global](https://premium.wpmudev.org/wp-content/uploads/2009/09/gstags1.png) 40 | 41 | On the off chance the page isn't auto created all you need to do is create a page with the slug \"tags\" without the quotes if the plugin fails to auto-create the page. 42 | 43 | ![Global](https://premium.wpmudev.org/wp-content/uploads/2009/09/gstags2.png) 44 | 45 | **Changing how tags are displayed on your Tags page is as simple as:** 46 | 47 | 1\. Go to **Network Admin > Settings > Settings** 48 | 49 | ![Global](https://premium.wpmudev.org/wp-content/uploads/2009/09/gstags3.png) 50 | 51 | 2\. Scroll down the page to the Site Tags Section 3\. Select the number of tags you want shown on the Tags page, then select the number of listings you want to display per page - _this is the number of posts displayed on a page when you click on a tag on the Tags Page_ 52 | 53 | ![Global](https://premium.wpmudev.org/wp-content/uploads/2009/09/gstags4.png) 54 | 55 | 4\. Adjust the color scheme, if you like 5\. Add tags you don't want included on your Tags page and select your preferred Tag Cloud Order (either Tag count or Most Recent) and select the Post Type you want to display tags from. 56 | 57 | ![Global](https://premium.wpmudev.org/wp-content/uploads/2009/09/gstags5.png) 58 | 59 | 6.Scroll to the Bottom and Click **Save Changes ** 60 | 61 | ![Global](https://premium.wpmudev.org/wp-content/uploads/2009/09/gstags6.png) 62 | 63 | **Adding a Global Tags widget to your homepage** Before you can use the Global Tags Widget you will need to Activate it in the Plugins menu of your Main Blog. 64 | 65 | ![Global](https://premium.wpmudev.org/wp-content/uploads/2009/09/gstags8.png) 66 | 67 | 1\. To add the widget to your homepage just go **Appearance > Widgets** 68 | 69 | ![Global](https://premium.wpmudev.org/wp-content/uploads/2009/09/gstags71.png) 70 | 71 | 2\. And add the Global Site Tags widget to your sidebar 72 | 73 | ![Global](https://premium.wpmudev.org/wp-content/uploads/2009/09/gstags9.png) 74 | 75 | 3\. Select your Options 76 | 77 | ![Global](https://premium.wpmudev.org/wp-content/uploads/2009/09/gstags10.png) 78 | 79 | And you're good to go! **Your users can now easily use your new Global Site Tags! It's as easy as:** - Go to the Tag page or Tag Cloud on the homepage - Click on the tag they want to check out 80 | 81 | ![Global](https://premium.wpmudev.org/wp-content/uploads/2009/09/gstags11.png) 82 | 83 | 3\. This opens up a chronological, paginated list - with avatars of all the posts for that particular tag: 84 | 85 | ![Global](https://premium.wpmudev.org/wp-content/uploads/2009/09/gstags12.png) 86 | 87 | **Please note:** 88 | 89 | * Tags on private posts display on the Global Site tags page but if you click on the link and no posts are listed this means they are all posts on private blogs (only visible to logged in users). 90 | * To display avatars your users will need to upload their avatar via their **Profile**. 91 | -------------------------------------------------------------------------------- /widget-global-site-tags.php: -------------------------------------------------------------------------------- 1 | __( 'Displays tags from all blogs', 'globalsitetags' ), 16 | ) ); 17 | } 18 | 19 | //Displays the Widget 20 | function widget( $args, $instance ) { 21 | global $globalsitetags; 22 | 23 | if (!is_object($globalsitetags)) return; 24 | 25 | extract( $args ); 26 | 27 | // Before the widget 28 | echo $before_widget; 29 | 30 | // The title 31 | $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Tags', 'globalsitetags' ) : $instance['title'] ); 32 | if ( $title ) { 33 | echo $before_title . $title . $after_title; 34 | } 35 | 36 | // Render tags cloud 37 | echo $globalsitetags->global_site_tags_tag_cloud( '', $instance['number'], $instance['low_font_size'], $instance['high_font_size'], false, $instance['poststype'] ); 38 | 39 | // After the widget 40 | echo $after_widget; 41 | } 42 | 43 | //Saves the widgets settings. 44 | function update( $new_instance, $old_instance ) { 45 | $instance = $old_instance; 46 | $instance['title'] = strip_tags( stripslashes( $new_instance['title'] ) ); 47 | $instance['tag_cloud_order'] = strip_tags( stripslashes( $new_instance['tag_cloud_order'] ) ); 48 | $instance['number'] = strip_tags( stripslashes( $new_instance['number'] ) ); 49 | $instance['high_font_size'] = strip_tags( stripslashes( $new_instance['high_font_size'] ) ); 50 | $instance['low_font_size'] = strip_tags( stripslashes( $new_instance['low_font_size'] ) ); 51 | $instance['poststype'] = strip_tags( stripslashes( $new_instance['poststype'] ) ); 52 | 53 | return $instance; 54 | } 55 | 56 | //Creates the edit form for the widget. 57 | function form( $instance ) { 58 | //Defaults 59 | $post_types = $this->get_post_types(); 60 | $instance = wp_parse_args( (array)$instance, array( 61 | 'title' => '', 62 | 'tag_cloud_order' => 'count', 63 | 'number' => 25, 64 | 'high_font_size' => 52, 65 | 'low_font_size' => 14, 66 | 'poststype' => 'post', 67 | ) ); 68 | 69 | //Output the options 70 | ?>

71 | 72 | 73 |

74 | 75 |

76 | 77 | 82 |

83 | 84 |

85 | 86 | 91 |

92 | 93 |

94 | 95 | 100 |

101 | 102 |

103 | 104 | 114 |

get_col( "SELECT post_type FROM {$wpdb->base_prefix}network_posts GROUP BY post_type" ); 120 | } 121 | 122 | } 123 | 124 | add_action( 'widgets_init', 'widget_global_site_tags_init' ); 125 | function widget_global_site_tags_init() { 126 | register_widget( 'widget_global_site_tags' ); 127 | } -------------------------------------------------------------------------------- /global-site-tags.php: -------------------------------------------------------------------------------- 1 | db = $wpdb; 47 | 48 | add_action( 'plugins_loaded', array( $this, 'global_site_tags_internationalisation' ) ); 49 | add_action( 'wpmu_options', array( $this, 'global_site_tags_site_admin_options' ) ); 50 | add_action( 'update_wpmu_options', array( $this, 'global_site_tags_site_admin_options_process' ) ); 51 | 52 | if ( GLOBAL_SITE_TAGS_BLOG == get_current_blog_id() ) { 53 | $installed = get_option( 'gst_installed', 0 ); 54 | if ( $installed < $this->build || $installed == 'yes' ) { 55 | add_action( 'init', array( $this, 'initialise_plugin' ) ); 56 | } 57 | 58 | // Add the rewrites 59 | add_action( 'generate_rewrite_rules', array( $this, 'add_rewrite' ) ); 60 | add_filter( 'query_vars', array( $this, 'add_queryvars' ) ); 61 | 62 | add_filter( 'the_content', array( $this, 'global_site_tags_output' ), 20 ); 63 | add_filter( 'the_title', array( $this, 'global_site_tags_title_output' ), 99, 2 ); 64 | } 65 | } 66 | 67 | function initialise_plugin() { 68 | // Flush the rules to add our pages 69 | flush_rewrite_rules(); 70 | // Add the default tag page 71 | $this->global_site_tags_page_setup(); 72 | // Set the option to say we are installed 73 | update_option( 'gst_installed', $this->build ); 74 | } 75 | 76 | function add_queryvars( $vars ) { 77 | // This function add the namespace (if it hasn't already been added) and the 78 | // eventperiod queryvars to the list that WordPress is looking for. 79 | // Note: Namespace provides a means to do a quick check to see if we should be doing anything 80 | 81 | if ( !in_array( 'namespace', $vars ) ) $vars[] = 'namespace'; 82 | if ( !in_array( 'tag', $vars ) ) $vars[] = 'tag'; 83 | if ( !in_array( 'paged', $vars ) ) $vars[] = 'paged'; 84 | if ( !in_array( 'type', $vars ) ) $vars[] = 'type'; 85 | 86 | return $vars; 87 | } 88 | 89 | function add_rewrite( $wp_rewrite ) { 90 | 91 | // This function adds in the api rewrite rules 92 | // Note the addition of the namespace variable so that we know these are vent based 93 | // calls 94 | $new_rules = array(); 95 | 96 | $new_rules[$this->global_site_tags_base . '/(.+)/page/?([0-9]{1,})'] = 'index.php?namespace=gst&tag=' . $wp_rewrite->preg_index(1) . '&paged=' . $wp_rewrite->preg_index(2) . '&type=tag&pagename=' . $this->global_site_tags_base; 97 | $new_rules[$this->global_site_tags_base . '/(.+)'] = 'index.php?namespace=gst&tag=' . $wp_rewrite->preg_index(1) . '&type=tag&pagename=' . $this->global_site_tags_base; 98 | $new_rules[$this->global_site_tags_base . ''] = 'index.php?namespace=gst&type=tag&pagename=' . $this->global_site_tags_base; 99 | 100 | $wp_rewrite->rules = $new_rules + $wp_rewrite->rules; 101 | 102 | return $wp_rewrite; 103 | 104 | } 105 | 106 | function global_site_tags_internationalisation() { 107 | // Load the text-domain 108 | load_plugin_textdomain( 'globalsitetags', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); 109 | } 110 | 111 | function global_site_tags_page_setup() { 112 | if ( get_option( 'global_site_tags_page_setup' ) != 'complete' && is_super_admin() ) { 113 | $page_id = get_option( 'global_site_tags_page' ); 114 | if ( empty( $page_id ) ) { 115 | // a page hasn't been set - so check if there is already one with the base name 116 | $page_id = $this->db->get_var( "SELECT ID FROM {$this->db->posts} WHERE post_name = '{$this->global_site_tags_base}' AND post_type = 'page'" ); 117 | if ( empty( $page_id ) ) { 118 | // Doesn't exist so create the page 119 | $page_id = wp_insert_post( array( 120 | "post_author" => get_current_user_id(), 121 | "post_date" => current_time( 'mysql' ), 122 | "post_date_gmt" => current_time( 'mysql' ), 123 | "post_content" => '', 124 | "post_title" => __( 'Tags', 'globalsitetags' ), 125 | "post_excerpt" => '', 126 | "post_status" => 'publish', 127 | "comment_status" => 'closed', 128 | "ping_status" => 'closed', 129 | "post_password" => '', 130 | "post_name" => $this->global_site_tags_base, 131 | "to_ping" => '', 132 | "pinged" => '', 133 | "post_modified" => current_time( 'mysql' ), 134 | "post_modified_gmt" => current_time( 'mysql' ), 135 | "post_content_filtered" => '', 136 | "post_parent" => 0, 137 | "menu_order" => 0, 138 | "post_type" => 'page', 139 | "comment_count" => 0 140 | ) ); 141 | } 142 | update_option( 'global_site_tags_page', $page_id ); 143 | } 144 | 145 | update_option( 'global_site_tags_page_setup', 'complete' ); 146 | } 147 | } 148 | 149 | function global_site_tags_site_admin_options() { 150 | $global_site_tags_per_page = get_site_option( 'global_site_tags_per_page', '10' ); 151 | $global_site_tags_shown = get_site_option( 'global_site_tags_shown', '50' ); 152 | $global_site_tags_background_color = get_site_option( 'global_site_tags_background_color', '#F2F2EA' ); 153 | $global_site_tags_alternate_background_color = get_site_option( 'global_site_tags_alternate_background_color', '#FFFFFF' ); 154 | $global_site_tags_border_color = get_site_option( 'global_site_tags_border_color', '#CFD0CB' ); 155 | $global_site_tags_banned_tags = get_site_option( 'global_site_tags_banned_tags', 'uncategorized' ); 156 | $global_site_tags_post_type = get_site_option( 'global_site_tags_post_type', 'post' ); 157 | $post_types = $this->global_site_tags_get_post_types(); 158 | 159 | ?>

160 | 161 | 162 | 163 | 164 | 171 | 172 | 173 | 174 | 181 | 182 | 183 | 184 | 188 | 189 | 190 | 191 | 195 | 196 | 197 | 198 | 202 | 203 | 204 | 205 | 209 | 210 | 211 | 212 | 220 | 221 |
165 | 170 |
175 | 180 |
185 | 186 |
: #F2F2EA 187 |
192 | 193 |
: #FFFFFF 194 |
199 | 200 |
: #CFD0CB 201 |
206 | 207 |
208 |
213 | 219 |
db->get_col( "SELECT post_type FROM " . $this->db->base_prefix . "network_posts GROUP BY post_type" ); 226 | } 227 | 228 | function global_site_tags_get_taxonomies() { 229 | return (array)$this->db->get_col( "SELECT taxonomy FROM {$this->db->base_prefix}network_term_taxonomy GROUP BY taxonomy" ); 230 | } 231 | 232 | function global_site_tags_site_admin_options_process() { 233 | update_site_option( 'global_site_tags_shown', $_POST['global_site_tags_shown'] ); 234 | update_site_option( 'global_site_tags_per_page', $_POST['global_site_tags_per_page'] ); 235 | update_site_option( 'global_site_tags_background_color', trim( $_POST['global_site_tags_background_color'] ) ); 236 | update_site_option( 'global_site_tags_alternate_background_color', trim( $_POST['global_site_tags_alternate_background_color'] ) ); 237 | update_site_option( 'global_site_tags_border_color', trim( $_POST['global_site_tags_border_color'] ) ); 238 | update_site_option( 'global_site_tags_banned_tags', trim( $_POST['global_site_tags_banned_tags'] ) ); 239 | update_site_option( 'global_site_tags_post_type', $_POST['global_site_tags_post_type'] ); 240 | } 241 | 242 | function global_site_tags_tag_cloud( $content, $number, $smallest, $largest, $cloud_banned_tags = false, $global_site_tags_post_type = 'post' ) { 243 | global $wpdb; 244 | 245 | $global_site_tags_banned_tags = get_site_option( 'global_site_tags_banned_tags', 'uncategorized' ); 246 | 247 | $banned_tags = array_map( 'trim', explode( ',', $global_site_tags_banned_tags ) ); 248 | if ( is_array( $cloud_banned_tags ) ) { 249 | $banned_tags = array_merge( $cloud_banned_tags, $banned_tags ); 250 | } 251 | 252 | $base_url = trailingslashit( trailingslashit( home_url() ) . $this->global_site_tags_base ); 253 | if ( GLOBAL_SITE_TAGS_BLOG != get_current_blog_id() ) { 254 | switch_to_blog( GLOBAL_SITE_TAGS_BLOG ); 255 | $base_url = trailingslashit( trailingslashit( home_url() ) . $this->global_site_tags_base ); 256 | restore_current_blog(); 257 | } 258 | 259 | $query = " 260 | SELECT COUNT(*) as 'count', 261 | t.term_id, 262 | t.term_id as id, 263 | t.name, 264 | t.slug, 265 | t.term_group, 266 | tt.term_taxonomy_id, 267 | tt.taxonomy, 268 | tt.description, 269 | tt.parent, 270 | CONCAT('{$base_url}', t.slug) as 'link' 271 | FROM {$this->db->base_prefix}network_terms as t 272 | INNER JOIN {$this->db->base_prefix}network_term_taxonomy AS tt ON t.term_id = tt.term_id 273 | INNER JOIN {$this->db->base_prefix}network_term_relationships AS tr ON tt.term_taxonomy_id = tr.term_taxonomy_id 274 | INNER JOIN {$this->db->base_prefix}network_posts AS np ON np.ID = tr.object_id AND np.BLOG_ID = tr.blog_id 275 | WHERE tt.taxonomy = 'post_tag'"; 276 | 277 | if ( !empty( $banned_tags ) ) { 278 | $banned_tags = implode( "', '", array_map( 'esc_sql', array_unique( array_filter( array_map( 'trim', $banned_tags ) ) ) ) ); 279 | $query .= " AND t.name NOT IN ('{$banned_tags}') "; 280 | } 281 | 282 | if ( $global_site_tags_post_type != 'all' ) { 283 | $query .= " AND np.post_type = '{$global_site_tags_post_type}'"; 284 | } 285 | 286 | $query .= " GROUP BY t.term_id ORDER BY 'count' DESC LIMIT " . $number; 287 | if (isset($_GET['TAGS_DEBUG'])) { 288 | echo "DEBUG: query[". $query ."]
"; 289 | } 290 | $thetags = $wpdb->get_results( $query ); 291 | $content .= !empty( $thetags ) 292 | ? wp_generate_tag_cloud( $thetags, array( 'smallest' => $smallest, 'largest' => $largest, 'unit' => 'px', 'number' => $number, 'orderby' => 'count', 'order' => 'DESC' ) ) 293 | : '

' . __( "There are no tags to display.", "globalsitetags" ) . '

'; 294 | 295 | return '
' . $content . '
'; 296 | } 297 | 298 | //------------------------------------------------------------------------// 299 | //---Output Functions-----------------------------------------------------// 300 | //------------------------------------------------------------------------// 301 | 302 | function global_site_tags_title_output( $title, $post_ID = '' ) { 303 | global $wpdb, $current_site, $post, $wp_query; 304 | 305 | if ( isset( $wp_query->query_vars['namespace'] ) && $wp_query->query_vars['namespace'] == 'gst' && $wp_query->query_vars['type'] == 'tag' && !empty( $wp_query->query_vars['tag'] ) ) { 306 | $page_id = get_option( 'global_site_tags_page' ); 307 | if ( ( !empty( $page_id ) && $page_id == $post_ID ) || ( !empty( $post ) && $post->ID == $post_ID ) ) { 308 | $tag_name = esc_sql( urldecode( $wp_query->query_vars['tag'] ) ); 309 | $tag_name = $wpdb->get_var( "SELECT name FROM {$wpdb->base_prefix}network_terms WHERE slug = '{$tag_name}'" ); 310 | 311 | $base_url = $current_site->domain . $current_site->path . $this->global_site_tags_base; 312 | $title = '' . $title . ' » ' . $tag_name . ''; 313 | } 314 | } 315 | 316 | return $title; 317 | } 318 | 319 | function global_site_tags_output( $content ) { 320 | global $wpdb, $current_site, $post, $global_site_tags_base, $members_directory_base, $network_query, $network_post, $wp_query; 321 | 322 | if ( !isset( $wp_query->query_vars['namespace'] ) || $wp_query->query_vars['namespace'] != 'gst' || $wp_query->query_vars['type'] != 'tag' ) { 323 | return $content; 324 | } 325 | 326 | $global_site_tags_shown = get_site_option( 'global_site_tags_shown', 50 ); 327 | $global_site_tags_per_page = get_site_option( 'global_site_tags_per_page', 10 ); 328 | $global_site_tags_background_color = get_site_option( 'global_site_tags_background_color', '#F2F2EA' ); 329 | $global_site_tags_alternate_background_color = get_site_option( 'global_site_tags_alternate_background_color', '#FFFFFF' ); 330 | $global_site_tags_border_color = get_site_option( 'global_site_tags_border_color', '#CFD0CB' ); 331 | $global_site_tags_post_type = get_site_option( 'global_site_tags_post_type', 'post' ); 332 | 333 | if ( empty( $wp_query->query_vars['tag'] ) ) { 334 | return $content . $this->global_site_tags_tag_cloud( $content, $global_site_tags_shown, 14, 52, '', $global_site_tags_post_type ); 335 | } 336 | 337 | // Show the results list for the tag 338 | //=====================================// 339 | 340 | // Set the page number 341 | network_query_posts( array( 342 | 'posts_per_page' => absint( $global_site_tags_per_page ), 343 | 'paged' => isset( $wp_query->query_vars['paged'] ) && $wp_query->query_vars['paged'] > 1 ? $wp_query->query_vars['paged'] : 1, 344 | 'tag' => urldecode( $wp_query->query_vars['tag'] ), 345 | 'post_type' => $global_site_tags_post_type != 'all' 346 | ? $global_site_tags_post_type 347 | : $this->global_site_tags_get_post_types(), 348 | ) ); 349 | 350 | if (isset($_GET['TAGS_DEBUG'])) { 351 | if (isset($GLOBALS['network_query'])) { 352 | echo "network_query
"; print_r($GLOBALS['network_query']); echo "
"; 353 | } 354 | } 355 | 356 | 357 | if ( !network_have_posts() ) { 358 | $content .= '

'; 359 | $content .= __( 'Nothing found for search term(s).', 'globalsitetags' ); 360 | $content .= '

'; 361 | 362 | return $content; 363 | } 364 | 365 | if ( isset( $GLOBALS['network_query']->found_posts ) && $GLOBALS['network_query']->found_posts > absint( $global_site_tags_per_page ) ) { 366 | $navigation_content = $this->new_pagination( $GLOBALS['network_query'], $current_site->path . $this->global_site_tags_base . '/' . urlencode( $wp_query->query_vars['tag'] ) ); 367 | } 368 | 369 | if ( isset( $navigation_content ) ) { 370 | $content .= $navigation_content; 371 | } 372 | 373 | $content .= '
'; 374 | $content .= ''; 375 | $content .= ''; 376 | $content .= ''; 377 | $content .= ''; 378 | $content .= ''; 379 | 380 | // Search results 381 | 382 | $members_directory_site_admin_options_exists = function_exists( 'members_directory_site_admin_options' ); 383 | $avatar_default = get_option( 'avatar_default' ); 384 | $tic_toc = 'toc'; 385 | 386 | while ( network_have_posts() ) { 387 | network_the_post(); 388 | 389 | //=============================// 390 | $author_id = network_get_the_author_id(); 391 | $the_author = get_user_by( 'id', $author_id ); 392 | $post_author_display_name = $the_author ? $the_author->display_name : __( 'Unknown', 'globalsitetags' ); 393 | 394 | $tic_toc = ($tic_toc == 'toc') ? 'tic' : 'toc'; 395 | $bg_color = ($tic_toc == 'tic') ? $global_site_tags_alternate_background_color : $global_site_tags_background_color; 396 | 397 | //=============================// 398 | $content .= ''; 399 | $content .= ''; 400 | $content .= ''; 408 | $content .= ''; 409 | } 410 | 411 | $content .= '
' . __( 'Posts', 'globalsitesearch' ) . '
' . get_avatar( $author_id, 32, $avatar_default ) . ''; 401 | $content .= '
'; 402 | $content .= $members_directory_site_admin_options_exists 403 | ? '' . $post_author_display_name . ' ' . __( ' wrote', 'globalsitetags' ) . ': ' 404 | : '' . sprintf( _x( '%s wrote', '{author name} wrote', 'globalsitetags' ), $post_author_display_name ) . ': '; 405 | $content .= '' . network_get_the_title() . '
'; 406 | $content .= substr( strip_tags( network_get_the_content() ), 0, 250 ) . ' (' . __( 'More', 'globalsitetags' ) . ')'; 407 | $content .= '
'; 412 | $content .= '
'; 413 | 414 | if ( isset( $navigation_content ) ) { 415 | $content .= $navigation_content; 416 | } 417 | 418 | return $content; 419 | 420 | } 421 | 422 | function new_pagination( $wp_query, $mainlink = '' ) { 423 | if ( $wp_query->max_num_pages > 1 ) { 424 | // we can draw the pages 425 | return '
' . paginate_links( array( 426 | 'base' => trailingslashit( $mainlink ) . '%_%', 427 | 'format' => 'page/%#%', 428 | 'total' => $wp_query->max_num_pages, 429 | 'current' => !empty( $wp_query->query_vars['paged'] ) ? $wp_query->query_vars['paged'] : 1, 430 | 'prev_next' => true 431 | ) ) . '
'; 432 | } 433 | } 434 | 435 | //------------------------------------------------------------------------// 436 | //---Page Output Functions------------------------------------------------// 437 | //------------------------------------------------------------------------// 438 | 439 | //------------------------------------------------------------------------// 440 | //---Support Functions----------------------------------------------------// 441 | //------------------------------------------------------------------------// 442 | 443 | function global_site_tags_roundup( $value, $dp ) { 444 | return ceil( $value * pow( 10, $dp ) ) / pow( 10, $dp ); 445 | } 446 | 447 | } 448 | 449 | $globalsitetags = new globalsitetags(); --------------------------------------------------------------------------------