Changeset 1670246
- Timestamp:
- 06/03/2017 04:20:14 PM (9 years ago)
- Location:
- project-description
- Files:
-
- 4 edited
- 6 copied
-
tags/0.0.2 (copied) (copied from project-description/trunk)
-
tags/0.0.2/css (copied) (copied from project-description/trunk/css)
-
tags/0.0.2/kantoniak-project-description.php (copied) (copied from project-description/trunk/kantoniak-project-description.php) (8 diffs)
-
tags/0.0.2/readme.txt (copied) (copied from project-description/trunk/readme.txt) (3 diffs)
-
tags/0.0.2/template-box.php (copied) (copied from project-description/trunk/template-box.php) (1 diff)
-
tags/0.0.2/template-settings.php (copied) (copied from project-description/trunk/template-settings.php) (1 diff)
-
trunk/kantoniak-project-description.php (modified) (8 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/template-box.php (modified) (1 diff)
-
trunk/template-settings.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
project-description/tags/0.0.2/kantoniak-project-description.php
r1642981 r1670246 4 4 Plugin URI: https://github.com/kantoniak/kantoniak-project-description/ 5 5 Description: This plugin adds project description at the top of the article. 6 Version: 0.0. 16 Version: 0.0.2 7 7 Author: Krzysztof Antoniak 8 8 Author URI: http://antoniak.in/ … … 18 18 const OPTION_SHOWFROMCAT = 'kantoniak_pd_showfromcat'; 19 19 const OPTION_CHANGEDESC = 'kantoniak_pd_changedesc'; 20 const OPTION_SHOWINSUBCAT = 'kantoniak_pd_showinsubcat'; 20 21 const OPTION_BOXTITLE = 'kantoniak_pd_boxtitle'; 21 22 const OPTION_BOXCONTENTS = 'kantoniak_pd_boxcontents'; … … 23 24 const OPTION_CATEGORY_NONE = -1; 24 25 const OPTION_CHANGEDESC_DEFAULT = false; 26 const OPTION_SHOWINSUBCAT_DEFAULT = false; 25 27 const OPTION_BOXTITLE_DEFAULT = 'About the project'; 26 28 const OPTION_BOXCONTENTS_DEFAULT = ''; … … 51 53 update_option(ProjectDescription::OPTION_SHOWFROMCAT, (boolean) $_POST['show_from_cat']); 52 54 update_option(ProjectDescription::OPTION_CHANGEDESC, (boolean) $_POST['change_cat_desc']); 55 update_option(ProjectDescription::OPTION_SHOWINSUBCAT, (boolean) $_POST['change_cat_desc'] ? (boolean) $_POST['show_in_subcat'] : false); 53 56 update_option(ProjectDescription::OPTION_BOXTITLE, $_POST['boxtitle']); 54 57 update_option(ProjectDescription::OPTION_BOXCONTENTS, $_POST['boxcontents']); … … 67 70 $showFromCat = (boolean) get_option(ProjectDescription::OPTION_SHOWFROMCAT, true); 68 71 $changeCatDesc = (boolean) get_option(ProjectDescription::OPTION_CHANGEDESC, ProjectDescription::OPTION_CHANGEDESC_DEFAULT); 72 $showInSubcat = (boolean) get_option(ProjectDescription::OPTION_SHOWINSUBCAT, ProjectDescription::OPTION_SHOWINSUBCAT_DEFAULT); 69 73 $boxTitle = get_option(ProjectDescription::OPTION_BOXTITLE, ProjectDescription::OPTION_BOXTITLE_DEFAULT); 70 74 $boxContents = get_option(ProjectDescription::OPTION_BOXCONTENTS, ProjectDescription::OPTION_BOXCONTENTS_DEFAULT); … … 82 86 83 87 public function onCategoryDescription($content) { 84 if (! is_category(get_option(ProjectDescription::OPTION_CATEGORY, ProjectDescription::OPTION_CATEGORY_NONE)) || !(boolean) get_option(ProjectDescription::OPTION_CHANGEDESC, ProjectDescription::OPTION_CHANGEDESC_DEFAULT)) {88 if (!(boolean) get_option(ProjectDescription::OPTION_CHANGEDESC, ProjectDescription::OPTION_CHANGEDESC_DEFAULT)) { 85 89 return $content; 86 90 } 87 91 88 return $this->renderBox(); 92 $category = get_option(ProjectDescription::OPTION_CATEGORY, ProjectDescription::OPTION_CATEGORY_NONE); 93 if (is_category($category)) { 94 return $this->renderBox(); 95 } 96 97 $changeSubCats = (boolean) get_option(ProjectDescription::OPTION_SHOWINSUBCAT, ProjectDescription::OPTION_SHOWINSUBCAT_DEFAULT); 98 if ($changeSubCats && $this->is_subcategory($category)) { 99 return $this->renderBox(); 100 } 101 102 return $content; 89 103 } 90 104 91 105 protected function renderBox() { 106 $category = get_option(ProjectDescription::OPTION_CATEGORY, ProjectDescription::OPTION_CATEGORY_NONE); 107 92 108 // List posts from the category 93 109 $others = get_posts(array( 94 'category' => get_option(ProjectDescription::OPTION_CATEGORY, ProjectDescription::OPTION_CATEGORY_NONE),110 'category' => $category, 95 111 'numberposts' => -1 96 112 )); … … 108 124 $postList = $postList; 109 125 $showFromCat = (boolean) get_option(ProjectDescription::OPTION_SHOWFROMCAT, true); 126 if ($showFromCat) { 127 $catName = get_cat_name($category); 128 } 110 129 111 130 ob_start(); … … 113 132 return ob_get_clean(); 114 133 } 134 135 protected function is_subcategory($cat) { 136 $subcategories = get_categories(array('child_of' => $cat)); 137 foreach($subcategories as $category) { 138 if (is_category($category->term_id)) { 139 return true; 140 } 141 } 142 return false; 143 } 115 144 } 116 145 -
project-description/tags/0.0.2/readme.txt
r1642981 r1670246 8 8 Author: Krzysztof Antoniak 9 9 Requires at least: 4.7.0 10 Tested up to: 4. 7.311 Stable tag: 0.0. 112 Version: 0.0. 110 Tested up to: 4.8.0 11 Stable tag: 0.0.2 12 Version: 0.0.2 13 13 License: GNU General Public License, version 3.0 (GPL-3.0) 14 14 License URI: https://www.gnu.org/licenses/gpl-3.0.en.html … … 21 21 * Set custom title and contents (full editor) 22 22 * Show in articles from single category 23 * Show in category archives (disabled by default) 23 * Show in category archives (disabled by default), optionally in subcategories 24 24 * Toggle "Jump to content" link 25 25 * Toggle article list visibility … … 38 38 Initial revision 39 39 40 = 0.0.2 = 41 Added option to show box in archive pages of subcategories. 42 40 43 == Screenshots == 41 44 1. Box preview -
project-description/tags/0.0.2/template-box.php
r1642981 r1670246 11 11 <?php if ($showFromCat) { ?> 12 12 <div class="other-posts"> 13 <p>See all the posts from this category:</p>13 <p>See all the posts from category “<?php echo $catName; ?>”:</p> 14 14 <ul class="other-posts-list"> 15 15 <?php -
project-description/tags/0.0.2/template-settings.php
r1642981 r1670246 43 43 <label for="change_cat_desc">Change category description in archives to description box</label> 44 44 <p class="description">Filter will return HTML code. Not every template shows category description.</p> 45 46 <div class="show_in_subcat_group" style="margin-top: 15px"> 47 <input name="show_in_subcat" type="checkbox" <?php echo ($showInSubcat ? ' checked' : ''); ?>> 48 <label for="show_in_subcat">Show also in subcategories</label> 49 <p class="description">Will run filter also for archive pages of subcategories.</p> 50 </div> 45 51 </td> 46 52 </tr> -
project-description/trunk/kantoniak-project-description.php
r1642981 r1670246 4 4 Plugin URI: https://github.com/kantoniak/kantoniak-project-description/ 5 5 Description: This plugin adds project description at the top of the article. 6 Version: 0.0. 16 Version: 0.0.2 7 7 Author: Krzysztof Antoniak 8 8 Author URI: http://antoniak.in/ … … 18 18 const OPTION_SHOWFROMCAT = 'kantoniak_pd_showfromcat'; 19 19 const OPTION_CHANGEDESC = 'kantoniak_pd_changedesc'; 20 const OPTION_SHOWINSUBCAT = 'kantoniak_pd_showinsubcat'; 20 21 const OPTION_BOXTITLE = 'kantoniak_pd_boxtitle'; 21 22 const OPTION_BOXCONTENTS = 'kantoniak_pd_boxcontents'; … … 23 24 const OPTION_CATEGORY_NONE = -1; 24 25 const OPTION_CHANGEDESC_DEFAULT = false; 26 const OPTION_SHOWINSUBCAT_DEFAULT = false; 25 27 const OPTION_BOXTITLE_DEFAULT = 'About the project'; 26 28 const OPTION_BOXCONTENTS_DEFAULT = ''; … … 51 53 update_option(ProjectDescription::OPTION_SHOWFROMCAT, (boolean) $_POST['show_from_cat']); 52 54 update_option(ProjectDescription::OPTION_CHANGEDESC, (boolean) $_POST['change_cat_desc']); 55 update_option(ProjectDescription::OPTION_SHOWINSUBCAT, (boolean) $_POST['change_cat_desc'] ? (boolean) $_POST['show_in_subcat'] : false); 53 56 update_option(ProjectDescription::OPTION_BOXTITLE, $_POST['boxtitle']); 54 57 update_option(ProjectDescription::OPTION_BOXCONTENTS, $_POST['boxcontents']); … … 67 70 $showFromCat = (boolean) get_option(ProjectDescription::OPTION_SHOWFROMCAT, true); 68 71 $changeCatDesc = (boolean) get_option(ProjectDescription::OPTION_CHANGEDESC, ProjectDescription::OPTION_CHANGEDESC_DEFAULT); 72 $showInSubcat = (boolean) get_option(ProjectDescription::OPTION_SHOWINSUBCAT, ProjectDescription::OPTION_SHOWINSUBCAT_DEFAULT); 69 73 $boxTitle = get_option(ProjectDescription::OPTION_BOXTITLE, ProjectDescription::OPTION_BOXTITLE_DEFAULT); 70 74 $boxContents = get_option(ProjectDescription::OPTION_BOXCONTENTS, ProjectDescription::OPTION_BOXCONTENTS_DEFAULT); … … 82 86 83 87 public function onCategoryDescription($content) { 84 if (! is_category(get_option(ProjectDescription::OPTION_CATEGORY, ProjectDescription::OPTION_CATEGORY_NONE)) || !(boolean) get_option(ProjectDescription::OPTION_CHANGEDESC, ProjectDescription::OPTION_CHANGEDESC_DEFAULT)) {88 if (!(boolean) get_option(ProjectDescription::OPTION_CHANGEDESC, ProjectDescription::OPTION_CHANGEDESC_DEFAULT)) { 85 89 return $content; 86 90 } 87 91 88 return $this->renderBox(); 92 $category = get_option(ProjectDescription::OPTION_CATEGORY, ProjectDescription::OPTION_CATEGORY_NONE); 93 if (is_category($category)) { 94 return $this->renderBox(); 95 } 96 97 $changeSubCats = (boolean) get_option(ProjectDescription::OPTION_SHOWINSUBCAT, ProjectDescription::OPTION_SHOWINSUBCAT_DEFAULT); 98 if ($changeSubCats && $this->is_subcategory($category)) { 99 return $this->renderBox(); 100 } 101 102 return $content; 89 103 } 90 104 91 105 protected function renderBox() { 106 $category = get_option(ProjectDescription::OPTION_CATEGORY, ProjectDescription::OPTION_CATEGORY_NONE); 107 92 108 // List posts from the category 93 109 $others = get_posts(array( 94 'category' => get_option(ProjectDescription::OPTION_CATEGORY, ProjectDescription::OPTION_CATEGORY_NONE),110 'category' => $category, 95 111 'numberposts' => -1 96 112 )); … … 108 124 $postList = $postList; 109 125 $showFromCat = (boolean) get_option(ProjectDescription::OPTION_SHOWFROMCAT, true); 126 if ($showFromCat) { 127 $catName = get_cat_name($category); 128 } 110 129 111 130 ob_start(); … … 113 132 return ob_get_clean(); 114 133 } 134 135 protected function is_subcategory($cat) { 136 $subcategories = get_categories(array('child_of' => $cat)); 137 foreach($subcategories as $category) { 138 if (is_category($category->term_id)) { 139 return true; 140 } 141 } 142 return false; 143 } 115 144 } 116 145 -
project-description/trunk/readme.txt
r1642981 r1670246 8 8 Author: Krzysztof Antoniak 9 9 Requires at least: 4.7.0 10 Tested up to: 4. 7.311 Stable tag: 0.0. 112 Version: 0.0. 110 Tested up to: 4.8.0 11 Stable tag: 0.0.2 12 Version: 0.0.2 13 13 License: GNU General Public License, version 3.0 (GPL-3.0) 14 14 License URI: https://www.gnu.org/licenses/gpl-3.0.en.html … … 21 21 * Set custom title and contents (full editor) 22 22 * Show in articles from single category 23 * Show in category archives (disabled by default) 23 * Show in category archives (disabled by default), optionally in subcategories 24 24 * Toggle "Jump to content" link 25 25 * Toggle article list visibility … … 38 38 Initial revision 39 39 40 = 0.0.2 = 41 Added option to show box in archive pages of subcategories. 42 40 43 == Screenshots == 41 44 1. Box preview -
project-description/trunk/template-box.php
r1642981 r1670246 11 11 <?php if ($showFromCat) { ?> 12 12 <div class="other-posts"> 13 <p>See all the posts from this category:</p>13 <p>See all the posts from category “<?php echo $catName; ?>”:</p> 14 14 <ul class="other-posts-list"> 15 15 <?php -
project-description/trunk/template-settings.php
r1642981 r1670246 43 43 <label for="change_cat_desc">Change category description in archives to description box</label> 44 44 <p class="description">Filter will return HTML code. Not every template shows category description.</p> 45 46 <div class="show_in_subcat_group" style="margin-top: 15px"> 47 <input name="show_in_subcat" type="checkbox" <?php echo ($showInSubcat ? ' checked' : ''); ?>> 48 <label for="show_in_subcat">Show also in subcategories</label> 49 <p class="description">Will run filter also for archive pages of subcategories.</p> 50 </div> 45 51 </td> 46 52 </tr>
Note: See TracChangeset
for help on using the changeset viewer.