Changeset 2089944
- Timestamp:
- 05/17/2019 02:19:09 PM (7 years ago)
- Location:
- taxonomy-thumbnail-widget
- Files:
-
- 48 added
- 13 edited
-
assets/banner-772x250.png (modified) (previous)
-
assets/icon-256x256.png (modified) (previous)
-
tags/1.4 (added)
-
tags/1.4/css (added)
-
tags/1.4/css/multiple-select.css (added)
-
tags/1.4/css/taxonomymanager.css (added)
-
tags/1.4/css/taxonomymanager_admin.css (added)
-
tags/1.4/img (added)
-
tags/1.4/img/multiple-select.png (added)
-
tags/1.4/img/placeholder.png (added)
-
tags/1.4/img/tax-setting.png (added)
-
tags/1.4/img/ttwsetting.png (added)
-
tags/1.4/js (added)
-
tags/1.4/js/multiple-select.js (added)
-
tags/1.4/js/taxonomymanager.js (added)
-
tags/1.4/lib (added)
-
tags/1.4/lib/taxonomy_widget.php (added)
-
tags/1.4/lib/taxonomymanager.php (added)
-
tags/1.4/lib/ttw_globaluse.php (added)
-
tags/1.4/lib/ttw_information.php (added)
-
tags/1.4/lib/ttw_shortcode.php (added)
-
tags/1.4/readme.txt (added)
-
tags/1.4/screenshot-1.png (added)
-
tags/1.4/screenshot-2.png (added)
-
tags/1.4/taxonomy-thumbnail-widget.php (added)
-
tags/1.4/uninstall.php (added)
-
tags/1.5 (added)
-
tags/1.5/css (added)
-
tags/1.5/css/multiple-select.css (added)
-
tags/1.5/css/taxonomymanager.css (added)
-
tags/1.5/css/taxonomymanager_admin.css (added)
-
tags/1.5/img (added)
-
tags/1.5/img/multiple-select.png (added)
-
tags/1.5/img/placeholder.png (added)
-
tags/1.5/img/tax-setting.png (added)
-
tags/1.5/img/ttwsetting.png (added)
-
tags/1.5/js (added)
-
tags/1.5/js/multiple-select.js (added)
-
tags/1.5/js/taxonomymanager.js (added)
-
tags/1.5/lib (added)
-
tags/1.5/lib/taxonomy_widget.php (added)
-
tags/1.5/lib/taxonomymanager.php (added)
-
tags/1.5/lib/ttw_globaluse.php (added)
-
tags/1.5/lib/ttw_information.php (added)
-
tags/1.5/lib/ttw_shortcode.php (added)
-
tags/1.5/readme.txt (added)
-
tags/1.5/screenshot-1.png (added)
-
tags/1.5/screenshot-2.png (added)
-
tags/1.5/taxonomy-thumbnail-widget.php (added)
-
tags/1.5/uninstall.php (added)
-
trunk/css/taxonomymanager.css (modified) (1 diff)
-
trunk/css/taxonomymanager_admin.css (modified) (1 diff)
-
trunk/js/taxonomymanager.js (modified) (2 diffs)
-
trunk/lib/taxonomy_widget.php (modified) (1 diff)
-
trunk/lib/taxonomymanager.php (modified) (7 diffs)
-
trunk/lib/ttw_globaluse.php (modified) (1 diff)
-
trunk/lib/ttw_information.php (modified) (1 diff)
-
trunk/lib/ttw_shortcode.php (modified) (1 diff)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/taxonomy-thumbnail-widget.php (modified) (1 diff)
-
trunk/uninstall.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
taxonomy-thumbnail-widget/trunk/css/taxonomymanager.css
r1567824 r2089944 1 1 .widget_taxonomytermlist .widget-title { 2 background: #242a3c none repeat scroll 0 0;3 color: #fff;4 font-size: 18px;5 padding: 5px;6 text-transform: uppercase;7 text-align: center;2 background: #242a3c none repeat scroll 0 0; 3 color: #fff; 4 font-size: 18px; 5 padding: 5px; 6 text-transform: uppercase; 7 text-align: center; 8 8 } 9 9 10 .widget_taxonomytermlist { 10 background: #f0f0f1 none repeat scroll 0 0;11 background: #f0f0f1 none repeat scroll 0 0; 11 12 } 13 12 14 .widget_taxonomytermlist .tax-term-container.in_sidebar { 13 padding: 0 10px 10px;14 list-style-type: none;15 margin: 0;15 padding: 0 10px 10px; 16 list-style-type: none; 17 margin: 0; 16 18 } 19 17 20 .widget_taxonomytermlist .tax-term-container.in_sidebar li { 18 border-bottom: 1px solid #dbdcdf;19 color: #8c8b8b;20 font-size: 14px;21 font-weight: 400;22 margin: 10px 0;21 border-bottom: 1px solid #dbdcdf; 22 color: #8c8b8b; 23 font-size: 14px; 24 font-weight: 400; 25 margin: 10px 0; 23 26 } 27 24 28 .widget_taxonomytermlist .tax-term-container.in_sidebar li:last-child { 25 border-bottom: medium none;29 border-bottom: medium none; 26 30 } 31 27 32 .widget_taxonomytermlist .tax-term-container.in_sidebar li a { 28 color: #8c8b8b;29 text-decoration: none;33 color: #8c8b8b; 34 text-decoration: none; 30 35 } 36 31 37 .widget_taxonomytermlist .tax-term-container.in_sidebar .img-container { 32 max-height: 200px;33 margin-bottom: 15px;34 overflow: hidden;38 max-height: 200px; 39 margin-bottom: 15px; 40 overflow: hidden; 35 41 } 42 36 43 .widget_taxonomytermlist .tax-term-container.in_sidebar .img-container { 37 max-width: 100%;38 height: auto;44 max-width: 100%; 45 height: auto; 39 46 } 47 40 48 .widget_taxonomytermlist .tax-term-container.in_sidebar .tax-title { 41 color: #242a3c;42 font-size: 17px;43 font-weight: 400;44 line-height: 24px;45 margin-bottom: 15px;46 text-transform: capitalize;49 color: #242a3c; 50 font-size: 17px; 51 font-weight: 400; 52 line-height: 24px; 53 margin-bottom: 15px; 54 text-transform: capitalize; 47 55 } 56 48 57 /** 49 58 * Shortcode Css 50 59 **/ 51 60 .ttw_pagination { 52 clear: both;53 font-size: 12px;54 line-height: 1.5em;55 margin: 20px 0;56 text-align: center;61 clear: both; 62 font-size: 12px; 63 line-height: 1.5em; 64 margin: 20px 0; 65 text-align: center; 57 66 } 67 58 68 .ttw_pagination ul.page-numbers li { 59 box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);60 display: inline-block;61 list-style: outside none none;62 margin: 0px;63 padding: 0px;69 box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05); 70 display: inline-block; 71 list-style: outside none none; 72 margin: 0px; 73 padding: 0px; 64 74 } 75 65 76 .ttw_pagination ul.page-numbers li:first-child, .ttw_pagination ul.page-numbers a:first-child { 66 border-radius: 3px 0 0 3px;77 border-radius: 3px 0 0 3px; 67 78 } 79 68 80 .ttw_pagination ul.page-numbers .page-numbers.current, .ttw_pagination ul.page-numbers li a:hover, .ttw_pagination ul.page-numbers li span:hover { 69 background: #242a3c none repeat scroll 0 0;70 border-color: #8c8b8b;71 color: #fff;81 background: #242a3c none repeat scroll 0 0; 82 border-color: #8c8b8b; 83 color: #fff; 72 84 } 85 73 86 .ttw_pagination ul.page-numbers span, .ttw_pagination ul.page-numbers a { 74 background-color: #fff;75 border: 1px solid #e8e8e8;76 color: #333;77 display: inline-block;78 margin-right: -1px;79 padding: 6px 12px;80 text-decoration: none;87 background-color: #fff; 88 border: 1px solid #e8e8e8; 89 color: #333; 90 display: inline-block; 91 margin-right: -1px; 92 padding: 6px 12px; 93 text-decoration: none; 81 94 } 95 82 96 .ttw-container .ttw-term-container { 83 box-sizing: border-box;84 list-style: outside none none;97 box-sizing: border-box; 98 list-style: outside none none; 85 99 } 100 86 101 .ttw-container .ttw-term-container li { 87 background: #f0f0f1 none repeat scroll 0 0;88 display: inline-block;89 margin: 5px;90 padding: 10px 10px 0;91 width: 28%;102 background: #f0f0f1 none repeat scroll 0 0; 103 display: inline-block; 104 margin: 5px; 105 padding: 10px 10px 0; 106 width: 28%; 92 107 } 108 93 109 .ttw-container .ttw-term-container .ttw-term-link { 94 text-decoration: none;110 text-decoration: none; 95 111 } 112 96 113 .ttw-container .ttw-term-container .ttw-term-title { 97 background: #242a3c none repeat scroll 0 0;98 color: #fff;99 font-size: 18px;100 padding: 5px;101 text-align: center;102 text-transform: uppercase;114 background: #242a3c none repeat scroll 0 0; 115 color: #fff; 116 font-size: 18px; 117 padding: 5px; 118 text-align: center; 119 text-transform: uppercase; 103 120 } 121 104 122 .ttw-container .ttw-term-container li .img-container { 105 min-height: 200px;106 width: 100%;123 min-height: 200px; 124 width: 100%; 107 125 } 126 108 127 .ttw-icon-container .ttw-term-icon-container { 109 list-style: outside none;128 list-style: outside none; 110 129 } 130 111 131 .ttw-icon-container .ttw-term-icon-container .ttw_term_icon_box { 112 display: inline-block;113 max-width: 200px;114 overflow: hidden;132 display: inline-block; 133 max-width: 200px; 134 overflow: hidden; 115 135 } 116 @media screen and (max-width:414px) { 117 .ttw-container .ttw-term-container li { 118 width: 100%; 119 overflow: hidden; 120 margin-left: 0px; 121 margin-right: 0px; 136 137 @media screen and (max-width: 414px) { 138 .ttw-container .ttw-term-container li { 139 width: 100%; 140 overflow: hidden; 141 margin-left: 0px; 142 margin-right: 0px; 143 } 122 144 } 145 146 @media screen and (max-width: 767px) { 147 .ttw-container .ttw-term-container li { 148 width: 100%; 149 overflow: hidden; 150 margin-left: 0px; 151 margin-right: 0px; 152 } 123 153 } 124 @media screen and (max-width:767px) { 125 .ttw-container .ttw-term-container li { 126 width: 100%; 127 overflow: hidden; 128 margin-left: 0px; 129 margin-right: 0px; 154 155 @media screen and (min-width: 768px) and (max-width: 991px) { 156 .ttw-container .ttw-term-container li { 157 width: 43%; 158 } 130 159 } 131 }132 @media screen and (min-width:768px) and (max-width:991px) {133 .ttw-container .ttw-term-container li {134 width: 43%;135 }136 } -
taxonomy-thumbnail-widget/trunk/css/taxonomymanager_admin.css
r1567824 r2089944 1 1 .ttwTabcontent, ul.ttwTab { 2 border: 1px solid #ccc;3 overflow: hidden2 border: 1px solid #ccc; 3 overflow: hidden 4 4 } 5 5 6 .taxonomy-manager-options { 6 width: 80%;7 margin: 0;8 padding: 10px 20px7 width: 80%; 8 margin: 0; 9 padding: 10px 20px 9 10 } 11 10 12 .ttw_author_details div { 11 float: left;12 overflow: hidden;13 padding: 5px;14 width: 48%13 float: left; 14 overflow: hidden; 15 padding: 5px; 16 width: 48% 15 17 } 18 16 19 .ttw_author_details span { 17 padding: 5px20 padding: 5px 18 21 } 22 19 23 ul.ttwTab { 20 list-style-type: none;21 margin: 0;22 padding: 0;23 background-color: #f1f1f124 list-style-type: none; 25 margin: 0; 26 padding: 0; 27 background-color: #f1f1f1 24 28 } 29 25 30 ul.ttwTab li { 26 float: left; 27 margin: 0; 28 overflow: hidden; 29 padding: 0 50px 31 float: left; 32 margin: 0; 33 overflow: hidden; 34 padding: 0 50px; 35 display: inline-block; 36 min-width: 25%; 30 37 } 38 31 39 ul.ttwTab li a { 32 display: inline-block;33 color: #000;34 text-align: center;35 padding: 14px 16px;36 text-decoration: none;37 transition: .3s;38 font-size: 17px40 display: inline-block; 41 color: #000; 42 text-align: center; 43 padding: 14px 16px; 44 text-decoration: none; 45 transition: .3s; 46 font-size: 17px 39 47 } 48 40 49 ul.ttwTab li a:hover { 41 background-color: #bee3d1;50 background-color: #bee3d1; 42 51 } 52 43 53 ul.ttwTab li .active, ul.ttwTab li a:focus { 44 background-color: #bee3d1;54 background-color: #bee3d1; 45 55 } 56 46 57 .ttwTabcontent { 47 display: none;48 padding: 6px 12px;49 border-top: none;50 box-sizing: border-box;51 min-height: 200px58 display: none; 59 padding: 6px 12px; 60 border-top: none; 61 box-sizing: border-box; 62 min-height: 200px 52 63 } 64 53 65 .ttwCloseBtn { 54 float: right;55 cursor: pointer;56 font-size: 20px66 float: right; 67 cursor: pointer; 68 font-size: 20px 57 69 } 70 58 71 .ttwCloseBtn:hover { 59 color: red72 color: red 60 73 } 74 61 75 .ttwTabcontent th, .ttwTabcontent td, .ttwTabcontent td a { 62 color: #fff;63 font-size: 16px;64 font-weight: 600;65 line-height: 20px;66 text-align: left;67 text-decoration: none76 color: #2d221d; 77 font-size: 16px; 78 font-weight: 600; 79 line-height: 20px; 80 text-align: left; 81 text-decoration: none 68 82 } 83 69 84 .plugin-description { 70 color: #fff;71 font-weight: 600;72 line-height: 16px;73 max-width: 80%;74 overflow: hidden;75 padding: 5px;76 text-decoration: none85 color: #2d221d; 86 font-weight: 600; 87 line-height: 16px; 88 max-width: 80%; 89 overflow: hidden; 90 padding: 5px; 91 text-decoration: none 77 92 } 93 78 94 .plugin-description li { 79 list-style: inside none lower-roman;95 list-style: inside none lower-roman; 80 96 } 97 81 98 .ttwcontactus input, .ttwcontactus textarea { 82 max-width: 500px;83 width: 80%99 max-width: 500px; 100 width: 80% 84 101 } 102 85 103 .ttwcontactus #ttwSubmit { 86 margin: 0 auto;87 max-width: 200px;88 text-align: center104 margin: 0 auto; 105 max-width: 200px; 106 text-align: center 89 107 } 108 90 109 section.informative { 91 background: #31a66c none repeat scroll 0 0; 92 box-shadow: 0 0 6px rgba(0, 0, 0, 0.4); 93 height: auto; 94 margin: 4rem auto; 95 max-width: 70rem; 96 min-width: 390px; 97 width: 80vw; 110 margin: 0 auto; 111 width: 90%; 98 112 } 113 99 114 .informative > h2 a { 100 color: rgba(0, 0, 0, 0.6);101 font-size: 1.5rem;102 font-weight: 600;103 text-align: center;104 text-decoration: none115 color: #2d221d; 116 font-size: 1.5rem; 117 font-weight: 600; 118 text-align: center; 119 text-decoration: none 105 120 } 121 106 122 img.custom_media_image[src=""] { 107 display: none;123 display: none; 108 124 } -
taxonomy-thumbnail-widget/trunk/js/taxonomymanager.js
r1567824 r2089944 1 jQuery(document).ready( function($) {2 function taxonomymanager_media_upload(button_class) {3 var _custom_media = true,4 _orig_send_attachment = wp.media.editor.send.attachment;5 $('body').on('click', button_class, function(e) {6 var button_id = '#'+$(this).attr('id');7 var send_attachment_bkp = wp.media.editor.send.attachment;8 var button = $(button_id);9 _custom_media = true;10 wp.media.editor.send.attachment = function(props, attachment){11 if ( _custom_media) {12 $('#taxonomy_thumb_id').val(attachment.id);13 $('#taxonomy-image-wrapper').html('<img class="custom_media_image" src="" style="margin:0;padding:0;max-height:100px;float:none;" />');14 $('#taxonomy-image-wrapper .custom_media_image').attr('src',attachment.sizes.full.url).css('display','block');15 } else {16 return _orig_send_attachment.apply( button_id, [props, attachment]);17 }1 jQuery(document).ready(function ($) { 2 function taxonomymanager_media_upload(button_class) { 3 var _custom_media = true, 4 _orig_send_attachment = wp.media.editor.send.attachment; 5 $('body').on('click', button_class, function (e) { 6 var button_id = '#' + $(this).attr('id'); 7 var send_attachment_bkp = wp.media.editor.send.attachment; 8 var button = $(button_id); 9 _custom_media = true; 10 wp.media.editor.send.attachment = function (props, attachment) { 11 if (_custom_media) { 12 $('#taxonomy_thumb_id').val(attachment.id); 13 $('#taxonomy-image-wrapper').html('<img class="custom_media_image" src="" style="margin:0;padding:0;max-height:100px;float:none;" />'); 14 $('#taxonomy-image-wrapper .custom_media_image').attr('src', attachment.sizes.full.url).css('display', 'block'); 15 } else { 16 return _orig_send_attachment.apply(button_id, [props, attachment]); 17 } 18 18 } 19 wp.media.editor.open(button); 20 return false; 21 }); 22 } 23 taxonomymanager_media_upload('.taxman_tax_media_button.button'); 24 $('body').on('click','.taxman_tax_media_remove',function(){ 25 $('#taxonomy_thumb_id').val(''); 26 $('#taxonomy-image-wrapper').html('<img class="custom_media_image" src="" style="margin:0;padding:0;max-height:100px;float:none;" />'); 27 }); 28 $(document).ajaxComplete(function(event, xhr, settings) { 29 var queryStringArr = settings.data.split('&'); 30 if( $.inArray('action=add-tag', queryStringArr) !== -1 ){ 31 var xml = xhr.responseXML; 32 $response = $(xml).find('term_id').text(); 33 if($response!=""){ 34 // Clear the thumb image 35 $('#taxonomy-image-wrapper').html(''); 36 } 37 } 38 }); 39 /*** 40 ** Add multiselect for taxonomies selection 41 ***/ 42 jQuery('#thumbnail_taxonomies').change(function() { 43 console.log(jQuery(this).val()); 44 }).multipleSelect({ 45 width: '230px' 46 }); 19 wp.media.editor.open(button); 20 return false; 21 }); 22 } 23 24 taxonomymanager_media_upload('.taxman_tax_media_button.button'); 25 $('body').on('click', '.taxman_tax_media_remove', function () { 26 $('#taxonomy_thumb_id').val(''); 27 $('#taxonomy-image-wrapper').html('<img class="custom_media_image" src="" style="margin:0;padding:0;max-height:100px;float:none;" />'); 28 }); 29 $(document).ajaxComplete(function (event, xhr, settings) { 30 var queryStringArr = settings.data.split('&'); 31 if ($.inArray('action=add-tag', queryStringArr) !== -1) { 32 var xml = xhr.responseXML; 33 $response = $(xml).find('term_id').text(); 34 if ($response != "") { 35 // Clear the thumb image 36 $('#taxonomy-image-wrapper').html(''); 37 } 38 } 39 }); 40 /*** 41 ** Add multiselect for taxonomies selection 42 ***/ 43 jQuery('#thumbnail_taxonomies').change(function () { 44 console.log(jQuery(this).val()); 45 }).multipleSelect({ 46 width: '230px' 47 }); 47 48 }); 48 49 … … 65 66 66 67 function ttwttwTabs(evt, tabName) { 67 var i, ttwTabcontent, ttwTablinks; 68 ttwTabcontent = document.getElementsByClassName("ttwTabcontent"); 69 for (i = 0; i < ttwTabcontent.length; i++) { 70 ttwTabcontent[i].style.display = "none"; 71 } 72 ttwTablinks = document.getElementsByClassName("ttwTablinks"); 73 for (i = 0; i < ttwTablinks.length; i++) { 74 ttwTablinks[i].className = ttwTablinks[i].className.replace(" active", ""); 75 } 76 document.getElementById(tabName).style.display = "block"; 77 evt.currentTarget.className += " active"; 78 } 79 if(currentpage == 'ttw_info'){ 80 document.getElementById("ttwDefaultOpen").click(); 68 var i, ttwTabcontent, ttwTablinks; 69 ttwTabcontent = document.getElementsByClassName("ttwTabcontent"); 70 for (i = 0; i < ttwTabcontent.length; i++) { 71 ttwTabcontent[i].style.display = "none"; 72 } 73 ttwTablinks = document.getElementsByClassName("ttwTablinks"); 74 for (i = 0; i < ttwTablinks.length; i++) { 75 ttwTablinks[i].className = ttwTablinks[i].className.replace(" active", ""); 76 } 77 document.getElementById(tabName).style.display = "block"; 78 evt.currentTarget.className += " active"; 81 79 } 82 80 81 if (currentpage == 'ttw_info') { 82 document.getElementById("ttwDefaultOpen").click(); 83 } 84 -
taxonomy-thumbnail-widget/trunk/lib/taxonomy_widget.php
r1567824 r2089944 1 1 <?php 2 add_action('widgets_init', create_function('', 'return register_widget("TaxonomyTermList");') ); 2 add_action('widgets_init', create_function('', 'return register_widget("TaxonomyTermList");')); 3 3 4 /** 4 5 * Adds TaxonomyTermList widget. 5 **/ 6 class TaxonomyTermList extends WP_Widget { 7 /** 8 * Register widget with WordPress. 9 */ 10 function __construct() { 11 parent::__construct( 12 'TaxonomyTermList',__( 'Taxonomy Term List', 'taxonomymanager' ), 13 array( 'description' => __( 'Taxonomy term list with thumbnail', 'taxonomymanager' ), ) 14 ); 15 } 16 /** 17 * Front-end display of widget. 18 **/ 19 public function widget( $args, $instance ) { 20 echo $args['before_widget']; 21 if ( ! empty( $instance['title'] ) ) { 22 echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title']; 23 } 24 $catArgs = array( 25 'taxonomy' => $instance['chooseTax'], 26 'hide_empty' =>($instance['hideEmpty'] == 'hide')? true : false, 27 'exclude' => $instance['excludeTerm'], 28 'number' => 0, 29 ); 30 $categoryList = get_terms($catArgs); 31 if(is_array($categoryList) && (count($categoryList) > 0)){ 32 $taxTermData = "<ul class='tax-term-container in_sidebar'>"; 33 foreach($categoryList as $cat){ 34 $termid = intval($cat->term_id); 35 $taxonomyName = wp_kses_data($cat->taxonomy); 36 $termname = wp_kses_data($cat->slug); 37 if($taxonomyName == 'product_cat'){ 38 $image_id = get_woocommerce_term_meta( $termid, 'thumbnail_id', true ); 39 }else{ 40 $image_id = get_term_meta ( $termid, 'taxonomy_thumb_id', true ); 41 } 42 $thumbnailSrc = wp_get_attachment_image_src ( $image_id,'full'); 43 $taxonomyName = $cat->taxonomy; 44 $term_Name = $cat->slug; 45 $getTermLink = get_term_link($termid,$taxonomyName); 6 **/ 7 class TaxonomyTermList extends WP_Widget 8 { 9 /** 10 * Register widget with WordPress. 11 */ 12 function __construct() 13 { 14 parent::__construct( 15 'TaxonomyTermList', __('Taxonomy Term List', 'taxonomymanager'), 16 array('description' => __('Taxonomy term list with thumbnail', 'taxonomymanager'),) 17 ); 18 } 46 19 47 if ( class_exists( 'WooCommerce' ) ) { 48 $wootaxonomies = wc_get_attribute_taxonomies(); 49 if(is_array($wootaxonomies)){ 50 foreach($wootaxonomies as $wootax){ 51 $taxname = wc_attribute_taxonomy_name( $wootax->attribute_name ); 52 if($taxonomyName == $taxname ){ 53 global $post; 54 $optionData = get_option('ttw_manager_settings'); 55 $postid = $optionData['ttw_woo_attribute_page']; 56 $pageLink = get_permalink($postid); 57 $queryData = base64_encode(json_encode( 58 array( 59 'wooAttrTax' => $taxonomyName, 60 'wooAttrTrm' => $term_Name, 61 'wooAttrID' => $termid, 62 ) 63 )); 64 $getTermLink = add_query_arg(array('ttwAttr'=>urlencode($queryData) ),$pageLink); 65 } 66 } 67 } 68 } 69 $thumbnailSrc = ($thumbnailSrc == '')?TTWTHUMB_URL:$thumbnailSrc[0]; 70 $taxTermData .= '<li class="tax-item term-'.$termid.'"><a href="'.$getTermLink.'" title="'.$termname.'"><div class="img-container"><img src="'.$thumbnailSrc.'"></div><div class="data-container"><span class="tax-title">'.$termname.'</span></div></a></li>'; 71 } 72 $taxTermData .= '</ul>'; 73 } 74 echo $taxTermData; 75 echo $args['after_widget']; 76 } 77 /** 78 * Back-end widget form. 79 **/ 80 public function form( $instance ) { 81 $title = ! empty( $instance['title'] ) ? $instance['title'] : __( '', 'taxonomymanager' ); 82 $hideEmpty = ! empty( $instance['hideEmpty'] ) ? $instance['hideEmpty'] : ''; 83 $excludeTerm = ! empty( $instance['excludeTerm'] ) ? $instance['excludeTerm'] : ''; 84 $chooseTax = ! empty( $instance['chooseTax'] ) ? $instance['chooseTax'] : ''; 85 ?> 86 <p> 87 <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( esc_attr( 'Title:' ) ); ?></label> 88 <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>"> 89 </p> 20 /** 21 * Front-end display of widget. 22 **/ 23 public function widget($args, $instance) 24 { 25 echo $args['before_widget']; 26 if (!empty($instance['title'])) { 27 echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title']; 28 } 29 $catArgs = array( 30 'taxonomy' => $instance['chooseTax'], 31 'hide_empty' => ($instance['hideEmpty'] == 'hide') ? true : false, 32 'exclude' => $instance['excludeTerm'], 33 'number' => 0, 34 ); 35 $categoryList = get_terms($catArgs); 36 if (is_array($categoryList) && (count($categoryList) > 0)) { 37 $taxTermData = "<ul class='tax-term-container in_sidebar'>"; 38 foreach ($categoryList as $cat) { 39 $termid = intval($cat->term_id); 40 $taxonomyName = wp_kses_data($cat->taxonomy); 41 $termname = wp_kses_data($cat->slug); 42 if ($taxonomyName == 'product_cat') { 43 $image_id = get_woocommerce_term_meta($termid, 'thumbnail_id', true); 44 } else { 45 $image_id = get_term_meta($termid, 'taxonomy_thumb_id', true); 46 } 47 $thumbnailSrc = wp_get_attachment_image_src($image_id, 'full'); 48 $taxonomyName = $cat->taxonomy; 49 $term_Name = $cat->slug; 50 $getTermLink = get_term_link($termid, $taxonomyName); 90 51 91 <p> 92 <?php 93 $getTaxData = get_option('ttw_manager_settings'); 94 if(!empty($getTaxData)){ 95 ?> 96 <label for="<?php echo esc_attr( $this->get_field_id('chooseTax')); ?>"><?php _e( esc_attr('Choose Taxonomy:')); ?></label> 97 <?php 98 $taxArrayData = $getTaxData['ttw_selected_taxonomies']; 99 if(is_array($taxArrayData)){ 100 $selectedTax = esc_attr($chooseTax); 101 ?> 102 <select class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'chooseTax' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'chooseTax' ) ); ?>" > 103 <?php 104 foreach($taxArrayData as $tax){ 105 ?> 106 <option value="<?php echo $tax; ?>" <?php if($selectedTax == $tax ){echo 'selected="selected"';}?>><?php echo $tax; ?></option> 107 <?php 108 } 109 ?></select><?php 110 } 111 }else{ 112 echo '<em>Please select <a href="'.admin_url( 'options-general.php?page=ttw_manager').'" title="TTW Settings">Taxonomies<a> first</em>'; 113 } 114 ?> 115 </p> 52 if (class_exists('WooCommerce')) { 53 $wootaxonomies = wc_get_attribute_taxonomies(); 54 if (is_array($wootaxonomies)) { 55 foreach ($wootaxonomies as $wootax) { 56 $taxname = wc_attribute_taxonomy_name($wootax->attribute_name); 57 if ($taxonomyName == $taxname) { 58 global $post; 59 $optionData = get_option('ttw_manager_settings'); 60 $postid = $optionData['ttw_woo_attribute_page']; 61 $pageLink = get_permalink($postid); 62 $queryData = base64_encode(json_encode( 63 array( 64 'wooAttrTax' => $taxonomyName, 65 'wooAttrTrm' => $term_Name, 66 'wooAttrID' => $termid, 67 ) 68 )); 69 $getTermLink = add_query_arg(array('ttwAttr' => urlencode($queryData)), $pageLink); 70 } 71 } 72 } 73 } 74 $thumbnailSrc = ($thumbnailSrc == '') ? TTWTHUMB_URL : $thumbnailSrc[0]; 75 $taxTermData .= '<li class="tax-item term-' . $termid . '"><a href="' . $getTermLink . '" title="' . $termname . '"><div class="img-container"><img src="' . $thumbnailSrc . '"></div><div class="data-container"><span class="tax-title">' . $termname . '</span></div></a></li>'; 76 } 77 $taxTermData .= '</ul>'; 78 } 79 echo $taxTermData; 80 echo $args['after_widget']; 81 } 82 83 /** 84 * Back-end widget form. 85 **/ 86 public function form($instance) 87 { 88 $title = !empty($instance['title']) ? $instance['title'] : __('', 'taxonomymanager'); 89 $hideEmpty = !empty($instance['hideEmpty']) ? $instance['hideEmpty'] : ''; 90 $excludeTerm = !empty($instance['excludeTerm']) ? $instance['excludeTerm'] : ''; 91 $chooseTax = !empty($instance['chooseTax']) ? $instance['chooseTax'] : ''; 92 ?> 93 <p> 94 <label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php _e(esc_attr('Title:')); ?></label> 95 <input class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>" 96 name="<?php echo esc_attr($this->get_field_name('title')); ?>" type="text" 97 value="<?php echo esc_attr($title); ?>"> 98 </p> 99 100 <p> 101 <?php 102 $getTaxData = get_option('ttw_manager_settings'); 103 if (!empty($getTaxData)) { 104 ?> 105 <label for="<?php echo esc_attr($this->get_field_id('chooseTax')); ?>"><?php _e(esc_attr('Choose Taxonomy:')); ?></label> 106 <?php 107 $taxArrayData = $getTaxData['ttw_selected_taxonomies']; 108 if (is_array($taxArrayData)) { 109 $selectedTax = esc_attr($chooseTax); 110 ?> 111 <select class="widefat" id="<?php echo esc_attr($this->get_field_id('chooseTax')); ?>" 112 name="<?php echo esc_attr($this->get_field_name('chooseTax')); ?>"> 113 <?php 114 foreach ($taxArrayData as $tax) { 115 ?> 116 <option value="<?php echo $tax; ?>" <?php if ($selectedTax == $tax) { 117 echo 'selected="selected"'; 118 } ?>><?php echo $tax; ?></option> 119 <?php 120 } 121 ?></select><?php 122 } 123 } else { 124 echo '<em>Please select <a href="' . admin_url('options-general.php?page=ttw_manager') . '" title="TTW Settings">Taxonomies<a> first</em>'; 125 } 126 ?> 127 </p> 116 128 117 129 130 <p> 131 <input class="widefat" id="<?php echo esc_attr($this->get_field_id('hideEmpty')); ?>" 132 name="<?php echo esc_attr($this->get_field_name('hideEmpty')); ?>" type="checkbox" 133 value="hide" <?php if ($hideEmpty == 'hide') { 134 echo 'checked'; 135 } ?> > 136 <label for="<?php echo esc_attr($this->get_field_id('hideEmpty')); ?>"><?php _e(esc_attr('Hide Empty')); ?></label> 137 </p> 138 <p> 139 <hr/> 140 <label for="<?php echo esc_attr($this->get_field_id('excludeTerm')); ?>"> 141 <?php _e(esc_attr('Exclude Terms')); ?> 142 </label> 143 <input class="widefat" id="<?php echo esc_attr($this->get_field_id('excludeTerm')); ?>" 144 name="<?php echo esc_attr($this->get_field_name('excludeTerm')); ?>" type="text" 145 value="<?php echo $excludeTerm; ?>"> 146 <br/> 147 <small>(input comma seprated term id's)</small> 148 </p> 149 <?php 150 } 118 151 119 <p> 120 <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'hideEmpty' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'hideEmpty' ) ); ?>" type="checkbox" value="hide" <?php if($hideEmpty == 'hide'){ echo 'checked'; } ?> > 121 <label for="<?php echo esc_attr( $this->get_field_id( 'hideEmpty' ) ); ?>"><?php _e( esc_attr( 'Hide Empty' ) ); ?></label> 122 </p> 123 <p> 124 <hr/> 125 <label for="<?php echo esc_attr( $this->get_field_id( 'excludeTerm' ) ); ?>"> 126 <?php _e( esc_attr( 'Exclude Terms' ) ); ?> 127 </label> 128 <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'excludeTerm' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'excludeTerm' ) ); ?>" type="text" value="<?php echo $excludeTerm; ?>" > 129 <br/><small>(input comma seprated term id's)</small> 130 </p> 131 <?php 132 } 133 /** 134 * Sanitize widget form values as they are saved. 135 **/ 136 public function update( $new_instance, $old_instance ) { 137 $instance = array(); 138 $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : ''; 139 $instance['chooseTax'] = ( ! empty( $new_instance['chooseTax'] ) ) ? strip_tags( $new_instance['chooseTax'] ) : ''; 140 $instance['hideEmpty'] = ( ! empty( $new_instance['hideEmpty'] ) ) ? strip_tags( $new_instance['hideEmpty'] ) : ''; 141 $instance['excludeTerm'] = ( ! empty( $new_instance['excludeTerm'] ) ) ? strip_tags( $new_instance['excludeTerm'] ) : ''; 142 return $instance; 143 } 152 /** 153 * Sanitize widget form values as they are saved. 154 **/ 155 public function update($new_instance, $old_instance) 156 { 157 $instance = array(); 158 $instance['title'] = (!empty($new_instance['title'])) ? strip_tags($new_instance['title']) : ''; 159 $instance['chooseTax'] = (!empty($new_instance['chooseTax'])) ? strip_tags($new_instance['chooseTax']) : ''; 160 $instance['hideEmpty'] = (!empty($new_instance['hideEmpty'])) ? strip_tags($new_instance['hideEmpty']) : ''; 161 $instance['excludeTerm'] = (!empty($new_instance['excludeTerm'])) ? strip_tags($new_instance['excludeTerm']) : ''; 162 return $instance; 163 } 144 164 } 165 145 166 ?> -
taxonomy-thumbnail-widget/trunk/lib/taxonomymanager.php
r1567824 r2089944 1 1 <?php 2 defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); 2 defined('ABSPATH') or die('No script kiddies please!'); 3 3 4 class TTWManagerSettingPage 4 5 { … … 13 14 public function __construct() 14 15 { 15 add_action( 'admin_menu', array( $this, 'ttw_manager_settingPageMenu' ) ); 16 add_action( 'admin_init', array( $this, 'ttw_manager_settingPageInit' ) ); 17 add_action( 'admin_init' , array( $this , 'ttw_contactUs_callback' ) ); 18 } 16 add_action('admin_menu', array($this, 'ttw_manager_settingPageMenu')); 17 add_action('admin_init', array($this, 'ttw_manager_settingPageInit')); 18 add_action('admin_init', array($this, 'ttw_contactUs_callback')); 19 } 20 19 21 /** 20 22 * Add options page … … 22 24 public function ttw_manager_settingPageMenu() 23 25 { 24 // Admin Menu Page 25 add_menu_page('TTW Settings','TTW Settings','manage_options','ttw_manager',array($this,'ttw_manager_settingsFormPage'), TTW_ICON); 26 add_submenu_page('ttw_manager','TTW Information','TTW Information','manage_options','ttw_info',array($this,'ttw_manager_infoPage')); 27 } 26 // Admin Menu Page 27 add_menu_page('TTW Settings', 'TTW Settings', 'manage_options', 'ttw_manager', array($this, 'ttw_manager_settingsFormPage'), TTW_ICON); 28 add_submenu_page('ttw_manager', 'TTW Information', 'TTW Information', 'manage_options', 'ttw_info', array($this, 'ttw_manager_infoPage')); 29 } 30 28 31 /** 29 32 * Options page callback 30 33 */ 31 public function ttw_manager_settingsFormPage(){ 34 public function ttw_manager_settingsFormPage() 35 { 32 36 // Set class property 33 $this->options = get_option( 'ttw_manager_settings');37 $this->options = get_option('ttw_manager_settings'); 34 38 ?> 35 39 <div class="wrap"> 36 40 <h1>Taxonomy Thumbmail And Widget Settings</h1> 37 41 <form method="post" action="options.php"> 38 <?php42 <?php 39 43 // This prints out all hidden setting fields 40 settings_fields( 'ttw_manager_settings_group');41 do_settings_sections( 'ttw-manager-admin-settings');44 settings_fields('ttw_manager_settings_group'); 45 do_settings_sections('ttw-manager-admin-settings'); 42 46 submit_button(); 43 ?>47 ?> 44 48 </form> 45 49 </div> 46 50 <?php 47 51 } 48 49 public function ttw_manager_infoPage(){ 50 echo '<section class="informative">'; 51 include(''.sprintf(TTWFILE_PATH.'lib/%s' , 'ttw_information.php').''); 52 echo '</section>'; 53 } 52 53 public function ttw_manager_infoPage() 54 { 55 echo '<section class="informative">'; 56 include('' . sprintf(TTWFILE_PATH . 'lib/%s', 'ttw_information.php') . ''); 57 echo '</section>'; 58 } 54 59 55 60 /** 56 61 * Register and add settings 57 62 */ 58 public function ttw_manager_settingPageInit() { 63 public function ttw_manager_settingPageInit() 64 { 59 65 register_setting( 60 66 'ttw_manager_settings_group', // Option group 61 67 'ttw_manager_settings', // Option name 62 array( $this, 'ttw_sanitize') // ttw_sanitize68 array($this, 'ttw_sanitize') // ttw_sanitize 63 69 ); 64 70 … … 66 72 'setting_section_id', // ID 67 73 'Select Taxonomies for which you want thumbnail:', // Title 68 array( $this, 'ttw_print_section_info'), // Callback74 array($this, 'ttw_print_section_info'), // Callback 69 75 'ttw-manager-admin-settings' // Page 70 ); 76 ); 71 77 72 78 add_settings_field( 73 'ttw_selected_taxonomies', 74 'Choose Taxonomies:', 75 array( $this, 'ttw_choose_taxonomies_callback' ),76 'ttw-manager-admin-settings', 79 'ttw_selected_taxonomies', 80 'Choose Taxonomies:', 81 array($this, 'ttw_choose_taxonomies_callback'), 82 'ttw-manager-admin-settings', 77 83 'setting_section_id' 78 ); 84 ); 79 85 } 80 86 … … 84 90 * @param array $input Contains all settings fields as array keys 85 91 */ 86 public function ttw_sanitize( $input ) { 92 public function ttw_sanitize($input) 93 { 87 94 $new_input = array(); 88 if ( isset( $input['ttw_selected_taxonomies'] ))89 $new_input['ttw_selected_taxonomies'] = $input['ttw_selected_taxonomies'];90 91 if ( isset( $input['ttw_woo_attribute_page'] ))92 $new_input['ttw_woo_attribute_page'] = $input['ttw_woo_attribute_page'];95 if (isset($input['ttw_selected_taxonomies'])) 96 $new_input['ttw_selected_taxonomies'] = $input['ttw_selected_taxonomies']; 97 98 if (isset($input['ttw_woo_attribute_page'])) 99 $new_input['ttw_woo_attribute_page'] = $input['ttw_woo_attribute_page']; 93 100 94 101 return $new_input; 95 102 } 96 103 97 /** 104 /** 98 105 * Print the Section text 99 106 */ 100 public function ttw_print_section_info() { 107 public function ttw_print_section_info() 108 { 101 109 print 'Enter your settings below:'; 102 110 } 103 /** 111 112 /** 104 113 * Get the settings option array and print one of its values 105 114 */ 106 public function ttw_choose_taxonomies_callback(){ 115 public function ttw_choose_taxonomies_callback() 116 { 107 117 $storedData = ''; 108 if (isset( $this->options['ttw_selected_taxonomies'] )){118 if (isset($this->options['ttw_selected_taxonomies'])) { 109 119 $storedData = $this->options['ttw_selected_taxonomies']; 110 120 } … … 113 123 $ttw_manager_settins .= '<select name="ttw_manager_settings[ttw_selected_taxonomies][]" id="thumbnail_taxonomies" multiple>'; 114 124 115 $catFlag = 0; 116 if (is_array($storedData)){117 if (in_array('category',$storedData)){125 $catFlag = 0; 126 if (is_array($storedData)) { 127 if (in_array('category', $storedData)) { 118 128 $catFlag = 1; 119 129 $ttw_manager_settins .= '<option value="category" selected="selected" >category</option>'; 120 130 } 121 131 } 122 if ($catFlag == 0){132 if ($catFlag == 0) { 123 133 $ttw_manager_settins .= '<option value="category" >category</option>'; 124 134 } 125 135 126 $tagFlag = 0;127 if (is_array($storedData)){128 if (in_array('post_tag',$storedData)){129 $tagFlag = 1;136 $tagFlag = 0; 137 if (is_array($storedData)) { 138 if (in_array('post_tag', $storedData)) { 139 $tagFlag = 1; 130 140 $ttw_manager_settins .= '<option value="post_tag" selected="selected" >post_tag</option>'; 131 141 } 132 142 } 133 if ($tagFlag == 0){143 if ($tagFlag == 0) { 134 144 $ttw_manager_settins .= '<option value="post_tag" >post_tag</option>'; 135 145 } 136 if ( class_exists( 'WooCommerce' )) {137 $taxonomies = get_taxonomies(array('public' => true,'_builtin' => false));138 $wootaxonomies =wc_get_attribute_taxonomies();139 if (is_array($wootaxonomies)){140 foreach ($wootaxonomies as $wootax){141 $taxname = wc_attribute_taxonomy_name( $wootax->attribute_name);146 if (class_exists('WooCommerce')) { 147 $taxonomies = get_taxonomies(array('public' => true, '_builtin' => false)); 148 $wootaxonomies = wc_get_attribute_taxonomies(); 149 if (is_array($wootaxonomies)) { 150 foreach ($wootaxonomies as $wootax) { 151 $taxname = wc_attribute_taxonomy_name($wootax->attribute_name); 142 152 array_push($taxonomies, $taxname); 143 153 } 144 154 } 145 155 array_unique($taxonomies); 146 } else{147 $taxonomies = get_taxonomies(array('public' => true,'_builtin' => false));156 } else { 157 $taxonomies = get_taxonomies(array('public' => true, '_builtin' => false)); 148 158 } 149 159 $taxonomies = array_unique($taxonomies); 150 foreach ( $taxonomies as $taxonomy) {160 foreach ($taxonomies as $taxonomy) { 151 161 $selectedTxt = ''; 152 if (is_array($storedData)){153 if (in_array($taxonomy,$storedData)){162 if (is_array($storedData)) { 163 if (in_array($taxonomy, $storedData)) { 154 164 $selectedTxt = 'selected="selected"'; 155 165 } 156 166 } 157 $ttw_manager_settins .= '<option value="' . $taxonomy . '" ' .$selectedTxt.' >' . $taxonomy . '</option>';167 $ttw_manager_settins .= '<option value="' . $taxonomy . '" ' . $selectedTxt . ' >' . $taxonomy . '</option>'; 158 168 } 159 169 $ttw_manager_settins .= '</Select>'; … … 161 171 162 172 } 163 164 /** 165 * Plugin Contact Us 166 **/ 167 public function ttw_contactUs_callback(){ 168 if(isset($_REQUEST['ttwContactUs']) && wp_verify_nonce( $_REQUEST['ttwContactUs'], 'ttwContact' ) ): 169 $blogName = sanitize_text_field(bloginfo('name')); 170 $blogUrl = esc_url(bloginfo('url')); 171 $blogAdminEmail = sanitize_email(bloginfo('admin_email')); 172 $contactSubject = sanitize_text_field($_REQUEST['ttwSubject']); 173 $contactMessage = esc_html($_REQUEST['ttwMessage']); 174 175 /** 176 * Filter the mail content type. 177 **/ 178 add_filter( 'wp_mail_content_type', array($this, 'ttw_set_html_mail_content_type' )); 179 180 /** 181 * Send mail to me : wp-admin TTW Setting contact us form submission 182 **/ 183 $headers[] = 'From: '.$blogName.' <'.$blogAdminEmail.'>'; 184 wp_mail( "sunilkumarthz@gmail.com", $contactSubject ,$contactMessage, $headers ); 185 186 /** 187 * Reset content-type to avoid conflicts 188 **/ 189 remove_filter( 'wp_mail_content_type', array($this, 'ttw_set_html_mail_content_type' )); 190 191 endif; 192 } 193 194 /** 195 * Filter the mail content type Callback function. 196 **/ 197 public function ttw_set_html_mail_content_type(){ 198 return 'text/html'; 199 } 173 174 /** 175 * Plugin Contact Us 176 **/ 177 public function ttw_contactUs_callback() 178 { 179 if (isset($_REQUEST['ttwContactUs']) && wp_verify_nonce($_REQUEST['ttwContactUs'], 'ttwContact')): 180 $blogName = sanitize_text_field(bloginfo('name')); 181 $blogUrl = esc_url(bloginfo('url')); 182 $blogAdminEmail = sanitize_email(bloginfo('admin_email')); 183 $contactSubject = sanitize_text_field($_REQUEST['ttwSubject']); 184 $contactMessage = esc_html($_REQUEST['ttwMessage']); 185 186 /** 187 * Filter the mail content type. 188 **/ 189 add_filter('wp_mail_content_type', array($this, 'ttw_set_html_mail_content_type')); 190 191 /** 192 * Send mail to me : wp-admin TTW Setting contact us form submission 193 **/ 194 $headers[] = 'From: ' . $blogName . ' <' . $blogAdminEmail . '>'; 195 wp_mail("sunilkumarthz@gmail.com", $contactSubject, $contactMessage, $headers); 196 197 /** 198 * Reset content-type to avoid conflicts 199 **/ 200 remove_filter('wp_mail_content_type', array($this, 'ttw_set_html_mail_content_type')); 201 202 endif; 203 } 204 205 /** 206 * Filter the mail content type Callback function. 207 **/ 208 public function ttw_set_html_mail_content_type() 209 { 210 return 'text/html'; 211 } 200 212 201 213 } 202 if( is_admin() ) 214 215 if (is_admin()) 203 216 $ttw_settings_page = new TTWManagerSettingPage(); 204 217 -
taxonomy-thumbnail-widget/trunk/lib/ttw_globaluse.php
r1531462 r2089944 1 1 <?php 2 defined( 'ABSPATH' ) or die( 'No script kiddies please!');2 defined('ABSPATH') or die('No script kiddies please!'); 3 3 /** 4 4 * Global function for get taxonomy thumbnail URL 5 **/ 6 if(!function_exists('ttw_thumbnail_url')): 7 function ttw_thumbnail_url($ttwID = null , $size = 'full'){ 8 if (!$ttwID) { 9 if (is_category()) 10 $ttwID = get_query_var('cat'); 11 elseif (is_tag()) 12 $ttwID = get_query_var('tag_id'); 13 elseif (is_tax()) { 14 $current_term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); 15 $ttwID = $current_term->term_id; 16 } 17 } 18 $taxonomyName = get_query_var('taxonomy'); 19 20 if(@$taxonomyName == 'product_cat'){ 21 $imageID = get_woocommerce_term_meta( $ttwID, 'thumbnail_id', true ); 22 }else{ 23 $imageID = get_term_meta ( $ttwID, 'taxonomy_thumb_id', true ); 24 } 25 26 $thumbnailSrc = wp_get_attachment_image_src ( $imageID,$size); 27 $thumbnailSrc = ($thumbnailSrc == '')?TTWTHUMB_URL:$thumbnailSrc[0]; 5 **/ 6 if (!function_exists('ttw_thumbnail_url')): 7 function ttw_thumbnail_url($ttwID = null, $size = 'full') 8 { 9 if (!$ttwID) { 10 if (is_category()) 11 $ttwID = get_query_var('cat'); 12 elseif (is_tag()) 13 $ttwID = get_query_var('tag_id'); 14 elseif (is_tax()) { 15 $current_term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); 16 $ttwID = $current_term->term_id; 17 } 18 } 19 $taxonomyName = get_query_var('taxonomy'); 28 20 29 return $thumbnailSrc; 30 } 21 if (@$taxonomyName == 'product_cat') { 22 $imageID = get_woocommerce_term_meta($ttwID, 'thumbnail_id', true); 23 } else { 24 $imageID = get_term_meta($ttwID, 'taxonomy_thumb_id', true); 25 } 26 27 $thumbnailSrc = wp_get_attachment_image_src($imageID, $size); 28 $thumbnailSrc = ($thumbnailSrc == '') ? TTWTHUMB_URL : $thumbnailSrc[0]; 29 30 return $thumbnailSrc; 31 } 31 32 endif; 32 33 33 34 /** 34 35 * Global function for get taxonomy thumbnail image 35 **/ 36 if(!function_exists('ttw_thumbnail_image')): 37 function ttw_thumbnail_image($ttwID = null , $size = 'full' ){ 38 if (!$ttwID) { 39 if (is_category()) 40 $ttwID = get_query_var('cat'); 41 elseif (is_tag()) 42 $ttwID = get_query_var('tag_id'); 43 elseif (is_tax()) { 44 $current_term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); 45 $ttwID = $current_term->term_id; 46 } 47 } 48 $taxonomyName = get_query_var('taxonomy'); 49 if(@$taxonomyName == 'product_cat'){ 50 $imageID = get_woocommerce_term_meta( $ttwID, 'thumbnail_id', true ); 51 }else{ 52 $imageID = get_term_meta ( $ttwID, 'taxonomy_thumb_id', true ); 53 } 54 $thumbnailSrc = wp_get_attachment_image( $imageID,$size); 55 return $thumbnailSrc; 56 } 36 **/ 37 if (!function_exists('ttw_thumbnail_image')): 38 function ttw_thumbnail_image($ttwID = null, $size = 'full') 39 { 40 if (!$ttwID) { 41 if (is_category()) 42 $ttwID = get_query_var('cat'); 43 elseif (is_tag()) 44 $ttwID = get_query_var('tag_id'); 45 elseif (is_tax()) { 46 $current_term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); 47 $ttwID = $current_term->term_id; 48 } 49 } 50 $taxonomyName = get_query_var('taxonomy'); 51 if (@$taxonomyName == 'product_cat') { 52 $imageID = get_woocommerce_term_meta($ttwID, 'thumbnail_id', true); 53 } else { 54 $imageID = get_term_meta($ttwID, 'taxonomy_thumb_id', true); 55 } 56 $thumbnailSrc = wp_get_attachment_image($imageID, $size); 57 return $thumbnailSrc; 58 } 57 59 endif; -
taxonomy-thumbnail-widget/trunk/lib/ttw_information.php
r1567824 r2089944 1 1 <?php 2 $body = (object) array( 'slug' => 'taxonomy-thumbnail-widget');2 $body = (object)array('slug' => 'taxonomy-thumbnail-widget'); 3 3 $post_data = array('action' => 'plugin_information', 'request' => serialize($body)); 4 $return = wp_remote_post( 'http://api.wordpress.org/plugins/info/1.0/', array( 'body' => $post_data ));5 $ttwPlugin = unserialize($return['body']); 4 $return = wp_remote_post('http://api.wordpress.org/plugins/info/1.0/', array('body' => $post_data)); 5 $ttwPlugin = unserialize($return['body']); 6 6 7 7 // _e( $ttwSlug, 'taxonomymanager' ); 8 $ttwSlug =$ttwPlugin->slug;9 $ttwName =$ttwPlugin->name;10 $ttwVersion =$ttwPlugin->version;11 $ttwRequire = $ttwPlugin->requires;12 $ttwTested = $ttwPlugin->tested;13 $ttwRating =$ttwPlugin->rating;14 $ttwPeoples =$ttwPlugin->num_ratings;15 $ttwDownload =$ttwPlugin->downloaded;16 $ttwLastUpdate =$ttwPlugin->last_updated;8 $ttwSlug = $ttwPlugin->slug; 9 $ttwName = $ttwPlugin->name; 10 $ttwVersion = $ttwPlugin->version; 11 $ttwRequire = $ttwPlugin->requires; 12 $ttwTested = $ttwPlugin->tested; 13 $ttwRating = $ttwPlugin->rating; 14 $ttwPeoples = $ttwPlugin->num_ratings; 15 $ttwDownload = $ttwPlugin->downloaded; 16 $ttwLastUpdate = $ttwPlugin->last_updated; 17 17 ?> 18 18 19 <h2 align="center"> <br /> 20 <a href="https://wordpress.org/plugins/<?php _e( $ttwSlug, 'taxonomymanager' ); ?>" title="<?php _e( $ttwName, 'taxonomymanager' ); ?>" target="_blank"><?php echo $ttwPlugin->name; ?></a></h2> 19 <h2 align="center"><br/> 20 <a href="https://wordpress.org/plugins/<?php _e($ttwSlug, 'taxonomymanager'); ?>" 21 title="<?php _e($ttwName, 'taxonomymanager'); ?>" target="_blank"><?php echo $ttwPlugin->name; ?></a></h2> 21 22 <ul class="ttwTab"> 22 <li><a href="javascript:void(0)" class="ttwTablinks" onclick="ttwttwTabs(event, 'pluginDetails')" id="ttwDefaultOpen">Plugin Details</a></li> 23 <li><a href="javascript:void(0)" class="ttwTablinks" onclick="ttwttwTabs(event, 'authorDetails')">Plugin Author Details </a></li> 24 <li><a href="javascript:void(0)" class="ttwTablinks" onclick="ttwttwTabs(event, 'pluginDescription')">Plugin Description</a></li> 23 <li><a href="javascript:void(0)" class="ttwTablinks" onclick="ttwttwTabs(event, 'pluginDetails')" 24 id="ttwDefaultOpen">Plugin Details</a></li> 25 <li><a href="javascript:void(0)" class="ttwTablinks" onclick="ttwttwTabs(event, 'authorDetails')">Plugin Author 26 Details </a></li> 27 <li><a href="javascript:void(0)" class="ttwTablinks" onclick="ttwttwTabs(event, 'pluginDescription')">Plugin 28 Description</a></li> 25 29 </ul> 26 <div id="pluginDetails" class="ttwTabcontent"> <span onclick="this.parentElement.style.display='none'" class="ttwCloseBtn">X</span> 27 <table align="left" cellpadding="4" cellspacing="4" border="0" width="100%"> 28 <tr> 29 <th>Plugin Version :</th> 30 <td><?php _e( $ttwVersion, 'taxonomymanager' ); ?></td> 31 </tr> 32 33 <th>Plugin Requires :</th> 34 <td><?php _e( $ttwRequire, 'taxonomymanager' ); ?></td> 35 </tr> 36 <tr> 37 <th>Plugin Tested :</th> 38 <td><?php _e( $ttwTested, 'taxonomymanager' ); ?></td> 39 </tr> 40 <tr> 41 <th>Plugin Rating :</th> 42 <td><?php _e( $ttwRating, 'taxonomymanager' ); ?> 43 by 44 <?php _e( $ttwPeoples, 'taxonomymanager' ); ?> 45 Peoples</td> 46 </tr> 47 <tr> 48 <th>Plugin Downloaded :</th> 49 <td><?php _e( $ttwDownload, 'taxonomymanager' ); ?></td> 50 </tr> 51 <tr> 52 <th>Plugin Last Updated :</th> 53 <td><?php _e( $ttwLastUpdate, 'taxonomymanager' ); ?></td> 54 </tr> 55 </table> 30 <div id="pluginDetails" class="ttwTabcontent"> 31 <table align="left" cellpadding="4" cellspacing="4" border="0" width="100%"> 32 <tr> 33 <th>Plugin Version :</th> 34 <td><?php _e($ttwVersion, 'taxonomymanager'); ?></td> 35 </tr> 36 37 <th>Plugin Requires :</th> 38 <td><?php _e($ttwRequire, 'taxonomymanager'); ?></td> 39 </tr> 40 <tr> 41 <th>Plugin Tested :</th> 42 <td><?php _e($ttwTested, 'taxonomymanager'); ?></td> 43 </tr> 44 <tr> 45 <th>Plugin Rating :</th> 46 <td><?php _e($ttwRating, 'taxonomymanager'); ?> 47 by 48 <?php _e($ttwPeoples, 'taxonomymanager'); ?> 49 Peoples 50 </td> 51 </tr> 52 <tr> 53 <th>Plugin Downloaded :</th> 54 <td><?php _e($ttwDownload, 'taxonomymanager'); ?></td> 55 </tr> 56 <tr> 57 <th>Plugin Last Updated :</th> 58 <td><?php _e($ttwLastUpdate, 'taxonomymanager'); ?></td> 59 </tr> 60 </table> 56 61 </div> 57 62 <?php 58 $ttwAuthor =$ttwPlugin->author;59 $ttwProfile =$ttwPlugin->author_profile;63 $ttwAuthor = $ttwPlugin->author; 64 $ttwProfile = $ttwPlugin->author_profile; 60 65 ?> 61 <div id="authorDetails" class="ttwTabcontent"> <span onclick="this.parentElement.style.display='none'" class="ttwCloseBtn">X</span> 62 <table align="left" cellpadding="4" cellspacing="4" border="0" width="100%"> 63 <tr> 64 <th>Plugin Author :</th> 65 <td><?php _e( $ttwAuthor, 'taxonomymanager' ); ?></td> 66 </tr> 67 <tr> 68 <th>Plugin Author Profile :</th> 69 <td><a href="<?php _e( $ttwProfile, 'taxonomymanager' ); ?>" title="sunilkumarthz">sunilkumarthz</a></td> 70 </tr> 71 <tr> 72 <th>Plugin Author EMail :</th> 73 <td><a href="mailto:sunilkumarthz@gmail.com" title="sunilkumarthz@gmail.com">sunilkumarthz@gmail.com</a></td> 74 </tr> 75 </table> 66 <div id="authorDetails" class="ttwTabcontent"> 67 <table align="left" cellpadding="4" cellspacing="4" border="0" width="100%"> 68 <tr> 69 <th>Plugin Author :</th> 70 <td><?php _e($ttwAuthor, 'taxonomymanager'); ?></td> 71 </tr> 72 <tr> 73 <th>Plugin Author Profile :</th> 74 <td><a href="<?php _e($ttwProfile, 'taxonomymanager'); ?>" title="sunilkumarthz">sunilkumarthz</a></td> 75 </tr> 76 <tr> 77 <th>Plugin Author EMail :</th> 78 <td><a href="mailto:sunilkumarthz@gmail.com" title="sunilkumarthz@gmail.com">sunilkumarthz@gmail.com</a> 79 </td> 80 </tr> 81 </table> 76 82 </div> 77 <div id="pluginDescription" class="ttwTabcontent"> <span onclick="this.parentElement.style.display='none'" class="ttwCloseBtn">X</span>78 <div class="plugin-description"><?php echo preg_replace('/(<br>)+$/', '', $ttwPlugin->sections['description']); ?></div>83 <div id="pluginDescription" class="ttwTabcontent"> 84 <div class="plugin-description"><?php echo preg_replace('/(<br>)+$/', '', $ttwPlugin->sections['description']); ?></div> 79 85 </div> 80 86 -
taxonomy-thumbnail-widget/trunk/lib/ttw_shortcode.php
r1567824 r2089944 1 1 <?php 2 defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); 3 if(!class_exists('TTWSHORTCODE')){ 4 class TTWSHORTCODE 5 { 6 function __construct(){ 7 add_shortcode('TTW_TERMS', array($this,'ttw_terms_list_callback')); 8 add_shortcode('TTW_POST_TERMS_ICON', array($this,'ttw_post_terms_icon_list_callback')); 9 } 10 /** 11 * Script For Show Data using shortcode 12 **/ 13 public function ttw_terms_list_callback($atts){ 14 ob_start(); 15 $atts = shortcode_atts(array( 16 'taxonomy' => 'category', 17 'class' => 'ttw_term_list', 18 'type' => 'list', 19 'hide_empty'=> true, 20 'exclude' => '', 21 'number' => get_option('posts_per_page'), 22 'offset' => '', 23 ),$atts); 24 25 $taxonomies = explode(',',$atts['taxonomy']); 26 $excludes = explode(',',$atts['exclude']); 27 $per_page = $atts['number']; 28 29 $getTaxCountArgs = array( 30 'hide_empty' => $atts['hide_empty'], 31 'exclude' => $excludes, 32 'cache_domain' => 'core' 33 ); 2 defined('ABSPATH') or die('No script kiddies please!'); 3 if (!class_exists('TTWSHORTCODE')) { 4 class TTWSHORTCODE 5 { 6 function __construct() 7 { 8 add_shortcode('TTW_TERMS', array($this, 'ttw_terms_list_callback')); 9 add_shortcode('TTW_POST_TERMS_ICON', array($this, 'ttw_post_terms_icon_list_callback')); 10 } 34 11 35 $page = ( get_query_var( 'page' ) ) ? get_query_var( 'page' ) : 1; 36 $offset = ( $page > 0 ) ? $per_page * ( $page - 1 ) : 1; 37 $totalterms = wp_count_terms( $taxonomies , $getTaxCountArgs ); 38 $totalpages = ceil( $totalterms / $per_page ); 39 $getTaxArgs = array( 40 'taxonomy' => $taxonomies, 41 'orderby' => 'name', 42 'order' => 'ASC', 43 'hide_empty' => $atts['hide_empty'], 44 'exclude' => $excludes, 45 'exclude_tree' => array(), 46 'include' => array(), 47 'number' => $per_page, 48 'fields' => 'all', 49 'slug' => '', 50 'parent' => '', 51 'hierarchical' => true, 52 'child_of' => 0, 53 'get' => '', 54 'name__like' => '', 55 'pad_counts' => false, 56 'offset' => $offset, 57 'search' => '', 58 'cache_domain' => 'core' 59 ); 60 $taxData = get_terms($getTaxArgs); 61 if(is_array($taxData)){ 62 $class = $atts['class']; 63 echo " <div class='ttw-container'><ul class='ttw-term-container ".$class."'>"; 64 foreach($taxData as $taxterm){ 65 $termID = intval($taxterm->term_id); 66 $taxonomyName = wp_kses_data($taxterm->taxonomy); 67 $termName = wp_kses_data($taxterm->slug); 68 if($taxonomyName == 'product_cat'){ 69 $imageID = get_woocommerce_term_meta( $termID, 'thumbnail_id', true ); 70 }else{ 71 $imageID = get_term_meta ( $termID, 'taxonomy_thumb_id', true ); 72 } 73 $thumbnailSrc = wp_get_attachment_image_src ( $imageID,'full'); 74 $thumbnailSrc = ($thumbnailSrc == '')?TTWTHUMB_URL:$thumbnailSrc[0]; 75 $getTermLink = get_term_link($termID,$taxonomyName); 76 ?> 77 <li class="ttw_term_box term-<?php echo $termID; ?>"> 78 <a class="ttw-term-link" title="<?php echo $taxterm->name; ?>" href="<?php echo $getTermLink; ?>"> 79 <div class="img-container"> 80 <img class="wp-post-image ttw_image" src="<?php echo $thumbnailSrc; ?>" alt="<?php echo $termName; ?>"> 81 </div> 82 <h3 class="ttw-term-title" itemprop="alternativeHeadline"><?php echo $taxterm->name; ?></h3> 83 </a> 84 </li> 85 <?php 86 } 87 echo "</ul></div>"; 88 } 89 printf( '<nav class="ttw_pagination">%s</nav>',$this->ttw_term_navigation( $totalpages, $page, 5, 0 )); 12 /** 13 * Script For Show Data using shortcode 14 **/ 15 public function ttw_terms_list_callback($atts) 16 { 17 ob_start(); 18 $atts = shortcode_atts(array( 19 'taxonomy' => 'category', 20 'class' => 'ttw_term_list', 21 'type' => 'list', 22 'hide_empty' => true, 23 'exclude' => '', 24 'number' => get_option('posts_per_page'), 25 'offset' => '', 26 ), $atts); 90 27 91 return ob_get_clean(); 92 } 93 94 /** 95 * Script For Show Data using shortcode 96 **/ 97 public function ttw_post_terms_icon_list_callback($atts){ 98 ob_start(); 99 $atts = shortcode_atts(array( 100 'taxonomy' => 'post_tag', 101 'class' => 'ttw_post_term_icon_list', 102 'type' => 'list', 103 'hide_empty'=> true, 104 'post_id' => '', 105 ),$atts); 106 107 $taxonomies = $atts['taxonomy']; 108 109 if(trim($atts['post_id']) == '' ){ 110 global $post; 111 $ttwpostID = $post->ID; 112 }else{ 113 $ttwpostID = trim($atts['post_id']); 114 } 115 116 117 $taxData = get_the_terms($ttwpostID , $taxonomies); 118 119 if(is_array($taxData)){ 120 $class = $atts['class']; 121 echo " <div class='ttw-icon-container'><ul class='ttw-term-icon-container ".$class."'>"; 122 foreach($taxData as $taxterm){ 123 $termID = intval($taxterm->term_id); 124 $taxonomyName = wp_kses_data($taxterm->taxonomy); 125 $termName = wp_kses_data($taxterm->slug); 126 if($taxonomyName == 'product_cat'){ 127 $imageID = get_woocommerce_term_meta( $termID, 'thumbnail_id', true ); 128 }else{ 129 $imageID = get_term_meta ( $termID, 'taxonomy_thumb_id', true ); 130 } 131 $thumbnailSrc = wp_get_attachment_image_src ( $imageID,'full'); 132 $thumbnailSrc = ($thumbnailSrc == '')?TTWTHUMB_URL:$thumbnailSrc[0]; 133 $getTermLink = get_term_link($termID,$taxonomyName); 134 ?> 135 <li class="ttw_term_icon_box term-<?php echo $termID; ?>"> 136 <a class="ttw-term-link" title="<?php echo $taxterm->name; ?>" href="<?php echo $getTermLink; ?>"> 137 <div class="icon-img-container"> 138 <img class="wp-post-image ttw_icon_image" src="<?php echo $thumbnailSrc; ?>" alt="<?php echo $termName; ?>"> 139 </div> 140 <h3 class="ttw-term-icon-title" itemprop="alternativeHeadline"><?php echo $taxterm->name; ?></h3> 141 </a> 142 </li> 143 <?php 144 } 145 echo "</ul></div>"; 146 } 147 28 $taxonomies = explode(',', $atts['taxonomy']); 29 $excludes = explode(',', $atts['exclude']); 30 $per_page = $atts['number']; 148 31 149 return ob_get_clean(); 150 } 151 152 public function ttw_term_navigation( $totalpages, $page, $end_size, $mid_size ){ 153 $ttwNum = 999999999; 154 if ( $totalpages <= 1 || $page > $totalpages ) return; 155 return paginate_links( array( 156 'base' => str_replace( $ttwNum, '%#%', esc_url( get_pagenum_link( $ttwNum ) ) ), 157 'format' => '', 158 'current' => max( 1, $page ), 159 'total' => $totalpages, 160 'prev_text' => 'Prev', 161 'next_text' => 'Next', 162 'type' => 'list', 163 'show_all' => false, 164 'end_size' => $end_size, 165 'mid_size' => $mid_size 166 )); 167 } 168 } 169 $ttwshortcode = new TTWSHORTCODE(); 32 $getTaxCountArgs = array( 33 'hide_empty' => $atts['hide_empty'], 34 'exclude' => $excludes, 35 'cache_domain' => 'core' 36 ); 37 38 $page = (get_query_var('page')) ? get_query_var('page') : 1; 39 $offset = ($page > 0) ? $per_page * ($page - 1) : 1; 40 $totalterms = wp_count_terms($taxonomies, $getTaxCountArgs); 41 $totalpages = ceil($totalterms / $per_page); 42 $getTaxArgs = array( 43 'taxonomy' => $taxonomies, 44 'orderby' => 'name', 45 'order' => 'ASC', 46 'hide_empty' => $atts['hide_empty'], 47 'exclude' => $excludes, 48 'exclude_tree' => array(), 49 'include' => array(), 50 'number' => $per_page, 51 'fields' => 'all', 52 'slug' => '', 53 'parent' => '', 54 'hierarchical' => true, 55 'child_of' => 0, 56 'get' => '', 57 'name__like' => '', 58 'pad_counts' => false, 59 'offset' => $offset, 60 'search' => '', 61 'cache_domain' => 'core' 62 ); 63 $taxData = get_terms($getTaxArgs); 64 if (is_array($taxData)) { 65 $class = $atts['class']; 66 echo " <div class='ttw-container'><ul class='ttw-term-container " . $class . "'>"; 67 foreach ($taxData as $taxterm) { 68 $termID = intval($taxterm->term_id); 69 $taxonomyName = wp_kses_data($taxterm->taxonomy); 70 $termName = wp_kses_data($taxterm->slug); 71 if ($taxonomyName == 'product_cat') { 72 $imageID = get_woocommerce_term_meta($termID, 'thumbnail_id', true); 73 } else { 74 $imageID = get_term_meta($termID, 'taxonomy_thumb_id', true); 75 } 76 $thumbnailSrc = wp_get_attachment_image_src($imageID, 'full'); 77 $thumbnailSrc = ($thumbnailSrc == '') ? TTWTHUMB_URL : $thumbnailSrc[0]; 78 $getTermLink = get_term_link($termID, $taxonomyName); 79 ?> 80 <li class="ttw_term_box term-<?php echo $termID; ?>"> 81 <a class="ttw-term-link" title="<?php echo $taxterm->name; ?>" 82 href="<?php echo $getTermLink; ?>"> 83 <div class="img-container"> 84 <img class="wp-post-image ttw_image" src="<?php echo $thumbnailSrc; ?>" 85 alt="<?php echo $termName; ?>"> 86 </div> 87 <h3 class="ttw-term-title" itemprop="alternativeHeadline"><?php echo $taxterm->name; ?></h3> 88 </a> 89 </li> 90 <?php 91 } 92 echo "</ul></div>"; 93 } 94 printf('<nav class="ttw_pagination">%s</nav>', $this->ttw_term_navigation($totalpages, $page, 5, 0)); 95 96 return ob_get_clean(); 97 } 98 99 /** 100 * Script For Show Data using shortcode 101 **/ 102 public function ttw_post_terms_icon_list_callback($atts) 103 { 104 ob_start(); 105 $atts = shortcode_atts(array( 106 'taxonomy' => 'post_tag', 107 'class' => 'ttw_post_term_icon_list', 108 'type' => 'list', 109 'hide_empty' => true, 110 'post_id' => '', 111 ), $atts); 112 113 $taxonomies = $atts['taxonomy']; 114 115 if (trim($atts['post_id']) == '') { 116 global $post; 117 $ttwpostID = $post->ID; 118 } else { 119 $ttwpostID = trim($atts['post_id']); 120 } 121 122 123 $taxData = get_the_terms($ttwpostID, $taxonomies); 124 125 if (is_array($taxData)) { 126 $class = $atts['class']; 127 echo " <div class='ttw-icon-container'><ul class='ttw-term-icon-container " . $class . "'>"; 128 foreach ($taxData as $taxterm) { 129 $termID = intval($taxterm->term_id); 130 $taxonomyName = wp_kses_data($taxterm->taxonomy); 131 $termName = wp_kses_data($taxterm->slug); 132 if ($taxonomyName == 'product_cat') { 133 $imageID = get_woocommerce_term_meta($termID, 'thumbnail_id', true); 134 } else { 135 $imageID = get_term_meta($termID, 'taxonomy_thumb_id', true); 136 } 137 $thumbnailSrc = wp_get_attachment_image_src($imageID, 'full'); 138 $thumbnailSrc = ($thumbnailSrc == '') ? TTWTHUMB_URL : $thumbnailSrc[0]; 139 $getTermLink = get_term_link($termID, $taxonomyName); 140 ?> 141 <li class="ttw_term_icon_box term-<?php echo $termID; ?>"> 142 <a class="ttw-term-link" title="<?php echo $taxterm->name; ?>" 143 href="<?php echo $getTermLink; ?>"> 144 <div class="icon-img-container"> 145 <img class="wp-post-image ttw_icon_image" src="<?php echo $thumbnailSrc; ?>" 146 alt="<?php echo $termName; ?>"> 147 </div> 148 <h3 class="ttw-term-icon-title" 149 itemprop="alternativeHeadline"><?php echo $taxterm->name; ?></h3> 150 </a> 151 </li> 152 <?php 153 } 154 echo "</ul></div>"; 155 } 156 157 158 return ob_get_clean(); 159 } 160 161 public function ttw_term_navigation($totalpages, $page, $end_size, $mid_size) 162 { 163 $ttwNum = 999999999; 164 if ($totalpages <= 1 || $page > $totalpages) return; 165 return paginate_links(array( 166 'base' => str_replace($ttwNum, '%#%', esc_url(get_pagenum_link($ttwNum))), 167 'format' => '', 168 'current' => max(1, $page), 169 'total' => $totalpages, 170 'prev_text' => 'Prev', 171 'next_text' => 'Next', 172 'type' => 'list', 173 'show_all' => false, 174 'end_size' => $end_size, 175 'mid_size' => $mid_size 176 )); 177 } 178 } 179 180 $ttwshortcode = new TTWSHORTCODE(); 170 181 } 171 182 ?> -
taxonomy-thumbnail-widget/trunk/readme.txt
r2082632 r2089944 1 1 === Taxonomy Thumbnail and Widget === 2 2 Contributors: sunilkumarthz 3 Tags: 1. 33 Tags: 1.4 4 4 Donate link: # 5 5 Requires at least: 4.6 6 Tested up to: 5. 17 Stable tag: 1. 36 Tested up to: 5.2 7 Stable tag: 1.4 8 8 License: GPLv3 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 33 33 * Drag and drop the widget `(Taxonomy Term List)` 34 34 * Shortcodes : 35 `[TTW_TERMS taxonomy='category' class='taxonomy-term-list']`35 `[TTW_TERMS taxonomy='category' class='taxonomy-term-list']` 36 36 37 For Show current post/product taxonomies37 For Show current post/product taxonomies 38 38 39 `[TTW_POST_TERMS_ICON taxonomy="product_tag" class="" hide_empty="" post_id=""]` 40 Note : 41 post_id is not required 42 taxonomy is required 39 `[TTW_POST_TERMS_ICON taxonomy="product_tag" class="" hide_empty="" post_id=""]` 40 41 Note : 42 post_id is not required 43 taxonomy is required 43 44 44 45 … … 103 104 * Add new shortcode 104 105 106 = 1.4 = 107 * Stablity Test With wordpress 5.1 105 108 109 110 -
taxonomy-thumbnail-widget/trunk/taxonomy-thumbnail-widget.php
r1567824 r2089944 4 4 * Plugin URI: https://wordpress.org/plugins/taxonomy-thumbnail-widget/ 5 5 * Description: Taxonomy Thumbnail and Widget plugin is used for add thumbnail option for inbuilt and custom taxonomy terms and access them with shortcode and widget 6 * Version: 1. 36 * Version: 1.5 7 7 * Author: Sunil Kumar Sharma 8 8 * Author URI: https://profiles.wordpress.org/sunilkumarthz 9 **/10 defined( 'ABSPATH' ) or die( 'No script kiddies please!');9 **/ 10 defined('ABSPATH') or die('No script kiddies please!'); 11 11 /** 12 ** Class for manage thumbnail for taxonomies 13 **/ 14 if ( ! class_exists( 'TaxonomyManagmentSystem' ) ) { 15 class TaxonomyManagmentSystem { 16 public function __construct() { 17 define('TTW_NAME' , 'Taxonomy Thumbnail And Widget'); 18 define('TTW_VERSION' , '1.1.0'); 19 define('TTWTHUMB_URL',plugin_dir_url( __FILE__ ).'img/placeholder.png'); 20 define('TTWFILE_PATH',plugin_dir_path( __FILE__ )); 21 define('TTWFILE_URL',plugin_dir_url( __FILE__ )); 22 define('TTW_ICON',plugin_dir_url( __FILE__ ).'img/ttwsetting.png'); 23 24 /** 25 * Taxonomy Thumbnail and Widget Plugin backend functionality 26 **/ 27 include(''.sprintf(TTWFILE_PATH.'lib/%s' , 'taxonomymanager.php').''); 28 /** 29 * Taxonomy Thumbnail and Widget Plugin widget functionality 30 **/ 31 include(''.sprintf(TTWFILE_PATH.'lib/%s' , 'taxonomy_widget.php').''); 32 /** 33 * Taxonomy Thumbnail and Widget Plugin Shortcode functionality 34 **/ 35 include(''.sprintf(TTWFILE_PATH.'lib/%s' , 'ttw_shortcode.php').''); 36 /** 37 * Taxonomy Thumbnail and Widget Plugin global functions 38 **/ 39 include(''.sprintf(TTWFILE_PATH.'lib/%s' , 'ttw_globaluse.php').''); 40 } 41 /** 42 ** Initialize the class and start calling our hooks and filters 43 **/ 44 public function init() { 45 add_action( 'wp_enqueue_scripts', array ( $this,'taxonomymanager_enqueue_style') ); 46 add_action( 'admin_enqueue_scripts', array ( $this,'load_taxonomymanager_wp_admin_style') ); 47 $getTaxData = get_option('ttw_manager_settings'); 48 if(!empty($getTaxData)): 49 $taxArrayData = @$getTaxData['ttw_selected_taxonomies']; 50 if (($ttwkey = array_search('product_cat', $taxArrayData)) !== false) { 51 unset($taxArrayData[$ttwkey]); 52 } 53 if(is_array($taxArrayData)){ 54 foreach($taxArrayData as $tax){ 55 add_filter( 'manage_'.trim($tax).'_custom_column', array ( $this,'ttw_manage_taxonomy_columns_data'), 15 , 3); 56 add_filter( 'manage_edit-'.trim($tax).'_columns', array ( $this,'ttw_taxonomy_columns_list')); 57 add_action( ''.trim($tax).'_add_form_fields', array ( $this, 'ttw_add_category_image' ), 10, 2 ); 58 add_action( 'created_'.trim($tax).'', array ( $this, 'ttw_save_category_image' ), 10, 2 ); 59 add_action( ''.trim($tax).'_edit_form_fields', array ( $this, 'ttw_update_category_image' ), 10, 2 ); 60 add_action( 'edited_'.trim($tax).'', array ( $this, 'ttw_updated_category_image' ), 10, 2 ); 61 } 62 } 63 endif; 64 add_filter( 'plugin_action_links_' . plugin_basename(__FILE__),array($this,'ttw_add_action_links') ); 65 } 66 67 /** 68 ** Add TTW Settings link 69 **/ 70 public function ttw_add_action_links ( $links ) { 71 $mylinks = array('<a href="' . admin_url( 'options-general.php?page=ttw_manager' ) . '">TTW Settings</a>',); 72 return array_merge( $links, $mylinks ); 73 } 74 75 /*** 76 ** Enqueue Scripts / styles for manage taxonomy front end widget layout 77 ***/ 78 public function taxonomymanager_enqueue_style(){ 79 wp_enqueue_style( 'taxonomymanager',sprintf(TTWFILE_URL.'css/%s' , 'taxonomymanager.css'), false ); 80 } 81 82 /*** 83 ** Enqueue Script for manage taxonomy backend 84 ***/ 85 public function load_taxonomymanager_wp_admin_style(){ 86 if(function_exists( 'wp_enqueue_media' )){ 87 wp_enqueue_media(); 88 }else{ 89 wp_enqueue_style('thickbox'); 90 wp_enqueue_script('media-upload'); 91 wp_enqueue_script('thickbox'); 92 } 93 wp_enqueue_style( 'taxonomymanager',sprintf(TTWFILE_URL.'css/%s' , 'taxonomymanager_admin.css'), true ); 94 wp_enqueue_style( 'multiple-select',sprintf(TTWFILE_URL.'css/%s' , 'multiple-select.css'),true ); 95 wp_enqueue_script( 'multiple-select',sprintf(TTWFILE_URL.'js/%s' , 'multiple-select.js'),false , array() , true ); 96 wp_enqueue_script( 'taxonomy-manager',sprintf(TTWFILE_URL.'js/%s' , 'taxonomymanager.js'),false , array() , true ); 97 } 98 99 /*** 100 ** add taxonomy column for thumbnail 101 ***/ 102 public function ttw_taxonomy_columns_list($original_columns) { 103 $new_columns = $original_columns; 104 array_splice( $new_columns, 1 ); 105 $new_columns['taxonomy_image'] = esc_html__( 'Image', 'taxonomymanager' ); 106 return array_merge( $new_columns, $original_columns ); 107 } 108 109 /*** 110 ** Manage taxonomy thumbnail column 111 ***/ 112 public function ttw_manage_taxonomy_columns_data($row, $column_name, $term_id) { 113 global $taxonomy; 114 if ( 'taxonomy_image' == $column_name ) { 115 $image_id = get_term_meta ( $term_id, 'taxonomy_thumb_id', true ); 116 $thumbnail = wp_get_attachment_image ( $image_id, array(100 , 100 )); 117 if($thumbnail ==''){ 118 return $row . "<img src='".TTWTHUMB_URL."' width='100px' />"; 119 }else{ 120 return $row . $thumbnail; 121 } 122 } 123 } 124 125 /*** 126 ** Add a form field in the new taxonomy page 127 ***/ 128 public function ttw_add_category_image ( $taxonomy ) { ?> 129 <div class="form-field term-group"> 130 <label for="taxonomy_thumb_id"><?php _e('Image', 'taxonomymanager'); ?></label> 131 <input type="hidden" id="taxonomy_thumb_id" name="taxonomy_thumb_id" class="custom_media_url" value=""> 132 <div id="taxonomy-image-wrapper"></div> 133 <p> 134 <input type="button" class="button button-secondary taxman_tax_media_button" id="taxman_tax_media_button" name="taxman_tax_media_button" value="<?php _e( 'Add Image', 'taxonomymanager' ); ?>" /> 135 <input type="button" class="button button-secondary taxman_tax_media_remove" id="taxman_tax_media_remove" name="taxman_tax_media_remove" value="<?php _e( 'Remove Image', 'taxonomymanager' ); ?>" /> 136 </p> 137 </div> 138 <?php 139 } 140 141 /*** 142 ** Save the form field 143 ***/ 144 public function ttw_save_category_image ( $term_id, $tt_id ) { 145 if( isset( $_POST['taxonomy_thumb_id'] ) && '' !== intval($_POST['taxonomy_thumb_id'])){ 146 $image = intval($_POST['taxonomy_thumb_id']); 147 add_term_meta( $term_id, 'taxonomy_thumb_id', $image, true ); 148 } 149 } 150 151 /*** 152 ** Edit the form field 153 ***/ 154 public function ttw_update_category_image ( $term, $taxonomy ) { ?> 155 <tr class="form-field term-group-wrap"> 156 <th scope="row"> 157 <label for="taxonomy_thumb_id"><?php _e( 'Image', 'taxonomymanager' ); ?></label> 158 </th> 159 <td> 160 <?php $image_id = get_term_meta ( $term -> term_id, 'taxonomy_thumb_id', true ); ?> 161 <input type="hidden" id="taxonomy_thumb_id" name="taxonomy_thumb_id" value="<?php echo $image_id; ?>"> 162 <div id="taxonomy-image-wrapper"> 163 <?php if ( $image_id ) { ?> 164 <?php echo wp_get_attachment_image ( $image_id, 'thumbnail' ); ?> 165 <?php } ?> 166 </div> 167 <p> 168 <input type="button" class="button button-secondary taxman_tax_media_button" id="taxman_tax_media_button" name="taxman_tax_media_button" value="<?php _e( 'Add Image', 'taxonomymanager' ); ?>" /> 169 <input type="button" class="button button-secondary taxman_tax_media_remove" id="taxman_tax_media_remove" name="taxman_tax_media_remove" value="<?php _e( 'Remove Image', 'taxonomymanager' ); ?>" /> 170 </p> 171 </td> 172 </tr> 173 <?php 174 } 175 176 /*** 177 ** Update the form field value 178 **/ 179 public function ttw_updated_category_image ( $term_id, $tt_id ) { 180 if( isset( $_POST['taxonomy_thumb_id'] ) && '' !== intval($_POST['taxonomy_thumb_id'])){ 181 $image = intval($_POST['taxonomy_thumb_id']); 182 update_term_meta ( $term_id, 'taxonomy_thumb_id', $image ); 183 } else { 184 update_term_meta ( $term_id, 'taxonomy_thumb_id', '' ); 185 } 186 } 12 ** Class for manage thumbnail for taxonomies 13 **/ 14 if (!class_exists('TaxonomyManagmentSystem')) { 15 class TaxonomyManagmentSystem 16 { 17 public function __construct() 18 { 19 define('TTW_NAME', 'Taxonomy Thumbnail And Widget'); 20 define('TTW_VERSION', '1.1.0'); 21 define('TTWTHUMB_URL', plugin_dir_url(__FILE__) . 'img/placeholder.png'); 22 define('TTWFILE_PATH', plugin_dir_path(__FILE__)); 23 define('TTWFILE_URL', plugin_dir_url(__FILE__)); 24 define('TTW_ICON', plugin_dir_url(__FILE__) . 'img/ttwsetting.png'); 25 26 /** 27 * Taxonomy Thumbnail and Widget Plugin backend functionality 28 **/ 29 include('' . sprintf(TTWFILE_PATH . 'lib/%s', 'taxonomymanager.php') . ''); 30 /** 31 * Taxonomy Thumbnail and Widget Plugin widget functionality 32 **/ 33 include('' . sprintf(TTWFILE_PATH . 'lib/%s', 'taxonomy_widget.php') . ''); 34 /** 35 * Taxonomy Thumbnail and Widget Plugin Shortcode functionality 36 **/ 37 include('' . sprintf(TTWFILE_PATH . 'lib/%s', 'ttw_shortcode.php') . ''); 38 /** 39 * Taxonomy Thumbnail and Widget Plugin global functions 40 **/ 41 include('' . sprintf(TTWFILE_PATH . 'lib/%s', 'ttw_globaluse.php') . ''); 42 } 43 44 /** 45 ** Initialize the class and start calling our hooks and filters 46 **/ 47 public function init() 48 { 49 add_action('wp_enqueue_scripts', array($this, 'taxonomymanager_enqueue_style')); 50 add_action('admin_enqueue_scripts', array($this, 'load_taxonomymanager_wp_admin_style')); 51 $getTaxData = get_option('ttw_manager_settings'); 52 if (!empty($getTaxData)): 53 $taxArrayData = @$getTaxData['ttw_selected_taxonomies']; 54 if (($ttwkey = array_search('product_cat', $taxArrayData)) !== false) { 55 unset($taxArrayData[$ttwkey]); 56 } 57 if (is_array($taxArrayData)) { 58 foreach ($taxArrayData as $tax) { 59 add_filter('manage_' . trim($tax) . '_custom_column', array($this, 'ttw_manage_taxonomy_columns_data'), 15, 3); 60 add_filter('manage_edit-' . trim($tax) . '_columns', array($this, 'ttw_taxonomy_columns_list')); 61 add_action('' . trim($tax) . '_add_form_fields', array($this, 'ttw_add_category_image'), 10, 2); 62 add_action('created_' . trim($tax) . '', array($this, 'ttw_save_category_image'), 10, 2); 63 add_action('' . trim($tax) . '_edit_form_fields', array($this, 'ttw_update_category_image'), 10, 2); 64 add_action('edited_' . trim($tax) . '', array($this, 'ttw_updated_category_image'), 10, 2); 65 } 66 } 67 endif; 68 add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'ttw_add_action_links')); 69 } 70 71 /** 72 ** Add TTW Settings link 73 **/ 74 public function ttw_add_action_links($links) 75 { 76 $mylinks = array('<a href="' . admin_url('options-general.php?page=ttw_manager') . '">TTW Settings</a>',); 77 return array_merge($links, $mylinks); 78 } 79 80 /*** 81 ** Enqueue Scripts / styles for manage taxonomy front end widget layout 82 ***/ 83 public function taxonomymanager_enqueue_style() 84 { 85 wp_enqueue_style('taxonomymanager', sprintf(TTWFILE_URL . 'css/%s', 'taxonomymanager.css'), false); 86 } 87 88 /*** 89 ** Enqueue Script for manage taxonomy backend 90 ***/ 91 public function load_taxonomymanager_wp_admin_style() 92 { 93 if (function_exists('wp_enqueue_media')) { 94 wp_enqueue_media(); 95 } else { 96 wp_enqueue_style('thickbox'); 97 wp_enqueue_script('media-upload'); 98 wp_enqueue_script('thickbox'); 99 } 100 wp_enqueue_style('taxonomymanager', sprintf(TTWFILE_URL . 'css/%s', 'taxonomymanager_admin.css'), true); 101 wp_enqueue_style('multiple-select', sprintf(TTWFILE_URL . 'css/%s', 'multiple-select.css'), true); 102 wp_enqueue_script('multiple-select', sprintf(TTWFILE_URL . 'js/%s', 'multiple-select.js'), false, array(), true); 103 wp_enqueue_script('taxonomy-manager', sprintf(TTWFILE_URL . 'js/%s', 'taxonomymanager.js'), false, array(), true); 104 } 105 106 /*** 107 ** add taxonomy column for thumbnail 108 ***/ 109 public function ttw_taxonomy_columns_list($original_columns) 110 { 111 $new_columns = $original_columns; 112 array_splice($new_columns, 1); 113 $new_columns['taxonomy_image'] = esc_html__('Image', 'taxonomymanager'); 114 return array_merge($new_columns, $original_columns); 115 } 116 117 /*** 118 ** Manage taxonomy thumbnail column 119 ***/ 120 public function ttw_manage_taxonomy_columns_data($row, $column_name, $term_id) 121 { 122 global $taxonomy; 123 if ('taxonomy_image' == $column_name) { 124 $image_id = get_term_meta($term_id, 'taxonomy_thumb_id', true); 125 $thumbnail = wp_get_attachment_image($image_id, array(100, 100)); 126 if ($thumbnail == '') { 127 return $row . "<img src='" . TTWTHUMB_URL . "' width='100px' />"; 128 } else { 129 return $row . $thumbnail; 130 } 131 } 132 } 133 134 /*** 135 ** Add a form field in the new taxonomy page 136 ***/ 137 public function ttw_add_category_image($taxonomy) 138 { ?> 139 <div class="form-field term-group"> 140 <label for="taxonomy_thumb_id"><?php _e('Image', 'taxonomymanager'); ?></label> 141 <input type="hidden" id="taxonomy_thumb_id" name="taxonomy_thumb_id" class="custom_media_url" value=""> 142 <div id="taxonomy-image-wrapper"></div> 143 <p> 144 <input type="button" class="button button-secondary taxman_tax_media_button" 145 id="taxman_tax_media_button" name="taxman_tax_media_button" 146 value="<?php _e('Add Image', 'taxonomymanager'); ?>"/> 147 <input type="button" class="button button-secondary taxman_tax_media_remove" 148 id="taxman_tax_media_remove" name="taxman_tax_media_remove" 149 value="<?php _e('Remove Image', 'taxonomymanager'); ?>"/> 150 </p> 151 </div> 152 <?php 153 } 154 155 /*** 156 ** Save the form field 157 ***/ 158 public function ttw_save_category_image($term_id, $tt_id) 159 { 160 if (isset($_POST['taxonomy_thumb_id']) && '' !== intval($_POST['taxonomy_thumb_id'])) { 161 $image = intval($_POST['taxonomy_thumb_id']); 162 add_term_meta($term_id, 'taxonomy_thumb_id', $image, true); 163 } 164 } 165 166 /*** 167 ** Edit the form field 168 ***/ 169 public function ttw_update_category_image($term, $taxonomy) 170 { ?> 171 <tr class="form-field term-group-wrap"> 172 <th scope="row"> 173 <label for="taxonomy_thumb_id"><?php _e('Image', 'taxonomymanager'); ?></label> 174 </th> 175 <td> 176 <?php $image_id = get_term_meta($term->term_id, 'taxonomy_thumb_id', true); ?> 177 <input type="hidden" id="taxonomy_thumb_id" name="taxonomy_thumb_id" 178 value="<?php echo $image_id; ?>"> 179 <div id="taxonomy-image-wrapper"> 180 <?php if ($image_id) { ?> 181 <?php echo wp_get_attachment_image($image_id, 'thumbnail'); ?> 182 <?php } ?> 183 </div> 184 <p> 185 <input type="button" class="button button-secondary taxman_tax_media_button" 186 id="taxman_tax_media_button" name="taxman_tax_media_button" 187 value="<?php _e('Add Image', 'taxonomymanager'); ?>"/> 188 <input type="button" class="button button-secondary taxman_tax_media_remove" 189 id="taxman_tax_media_remove" name="taxman_tax_media_remove" 190 value="<?php _e('Remove Image', 'taxonomymanager'); ?>"/> 191 </p> 192 </td> 193 </tr> 194 <?php 195 } 196 197 /*** 198 ** Update the form field value 199 **/ 200 public function ttw_updated_category_image($term_id, $tt_id) 201 { 202 if (isset($_POST['taxonomy_thumb_id']) && '' !== intval($_POST['taxonomy_thumb_id'])) { 203 $image = intval($_POST['taxonomy_thumb_id']); 204 update_term_meta($term_id, 'taxonomy_thumb_id', $image); 205 } else { 206 update_term_meta($term_id, 'taxonomy_thumb_id', ''); 207 } 208 } 209 } 210 211 $ttwSystem = new TaxonomyManagmentSystem(); 212 $ttwSystem->init(); 187 213 } 188 $ttwSystem = new TaxonomyManagmentSystem();189 $ttwSystem ->init();190 } -
taxonomy-thumbnail-widget/trunk/uninstall.php
r1567824 r2089944 1 1 <?php 2 defined( 'WP_UNINSTALL_PLUGIN' ) or die( 'No script kiddies please!');2 defined('WP_UNINSTALL_PLUGIN') or die('No script kiddies please!'); 3 3 4 if ( ! current_user_can( 'activate_plugins' )) {5 return;4 if (!current_user_can('activate_plugins')) { 5 return; 6 6 } 7 check_admin_referer( 'bulk-plugins');7 check_admin_referer('bulk-plugins'); 8 8 9 if ( __FILE__ != WP_UNINSTALL_PLUGIN) {10 return;9 if (__FILE__ != WP_UNINSTALL_PLUGIN) { 10 return; 11 11 } 12 12 13 if ( defined( 'MULTISITE' ) ){14 delete_site_option( 'ttw_manager_settings');15 } else{16 delete_option( 'ttw_manager_settings');13 if (defined('MULTISITE')) { 14 delete_site_option('ttw_manager_settings'); 15 } else { 16 delete_option('ttw_manager_settings'); 17 17 } 18 18 ?>
Note: See TracChangeset
for help on using the changeset viewer.