Changeset 3036977
- Timestamp:
- 02/16/2024 08:31:29 PM (2 years ago)
- Location:
- kitab/trunk
- Files:
-
- 2 added
- 5 edited
-
includes/classes/class-postmeta.php (modified) (10 diffs)
-
includes/classes/class-posttypes.php (added)
-
includes/classes/class-taxonomies.php (added)
-
includes/classes/options-tabs/layout-options.php (modified) (1 diff)
-
includes/public/class-layout.php (modified) (15 diffs)
-
kitab.php (modified) (1 diff)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
kitab/trunk/includes/classes/class-postmeta.php
r3032621 r3036977 124 124 'dashicon' => 'dashicons-book', 125 125 'emoji' => '📚', 126 'fontawesome' => 'fas fa-book', 126 127 'description' => esc_html__('Enter the name of the book', 'kitab'), 127 128 'priority' => 10 … … 133 134 'dashicon' => 'dashicons-admin-users', 134 135 'emoji' => '👨🏫', 136 'fontawesome' => 'fas fa-user', 135 137 'description' => esc_html__('Enter the name of the author', 'kitab'), 136 138 'priority' => 11 … … 141 143 'dashicon' => 'dashicons-admin-links', 142 144 'emoji' => '📄', 145 'fontawesome' => 'fas fa-file', 143 146 'description' => esc_html__('Enter the number of pages in the book', 'kitab'), 144 147 'priority' => 20 … … 149 152 'dashicon' => 'dashicons-clipboard', 150 153 'emoji' => '📑', 154 'fontawesome' => 'fas fa-clipboard', 151 155 'description' => esc_html__('Enter the edition of the book', 'kitab'), 152 156 'priority' => 30 … … 157 161 'dashicon' => 'dashicons-tag', 158 162 'emoji' => '🏷️', 163 'fontawesome' => 'fas fa-tag', 159 164 'description' => esc_html__('Enter the ISBN of the book', 'kitab'), 160 165 'priority' => 40 … … 165 170 'dashicon' => 'dashicons-calendar', 166 171 'emoji' => '📅', 172 'fontawesome' => 'fas fa-calendar', 167 173 'description' => esc_html__('Enter the year of copyright', 'kitab'), 168 174 'priority' => 50 … … 173 179 'dashicon' => 'dashicons-businessman', 174 180 'emoji' => '👨💼', 181 'fontawesome' => 'fas fa-user-tie', 175 182 'description' => esc_html__('Enter the name of the copyright holder', 'kitab'), 176 183 'priority' => 60 … … 181 188 'dashicon' => 'dashicons-download', 182 189 'emoji' => '📥', 190 'fontawesome' => 'fas fa-download', 183 191 'description' => esc_html__('Enter the URL of the PDF download link', 'kitab'), 184 192 'priority' => 70 … … 189 197 'dashicon' => 'dashicons-media-archive', 190 198 'emoji' => '📦', 199 'fontawesome' => 'fas fa-archive', 191 200 'description' => esc_html__('Enter the URL of the EPUB download link', 'kitab'), 192 201 'priority' => 80 … … 197 206 'dashicon' => 'dashicons-cart', 198 207 'emoji' => '🛒', 208 'fontawesome' => 'fas fa-shopping-cart', 199 209 'description' => esc_html__('Enter the URL of the buy link', 'kitab'), 200 210 'priority' => 90 -
kitab/trunk/includes/classes/options-tabs/layout-options.php
r3032621 r3036977 65 65 </td> 66 66 </tr> 67 <!-- checkbox for showing font awesome icon, ''must have font awoesome library on theme or plugin --> 68 <tr> 69 <th scope="row"><?php esc_html_e('Show Font Awesome Icons', 'kitab'); ?> 70 <p class="kitab-tooltip"> 71 <span class="description"><?php esc_html_e('Must have font awesome library on theme or plugin.', 'kitab'); ?></span> 72 <span class="dashicons dashicons-editor-help"></span> 73 </p> 74 </th> 75 <td> 76 <?php 77 $selected_show_font_awesome = isset(get_option($this->option_name)['show_font_awesome']) ? get_option($this->option_name)['show_font_awesome'] : ''; 78 ?> 79 <label> 80 <input type="checkbox" name="<?php echo esc_attr($this->option_name); ?>[show_font_awesome]" value="yes" <?php checked('yes', $selected_show_font_awesome); ?>> 81 <?php esc_html_e('Yes', 'kitab'); ?> 82 </label> 83 </td> 67 84 <tr> 68 85 <th scope="row"><?php esc_html_e('Disable Downloads in Copyrighted Claims Books', 'kitab'); ?></th> -
kitab/trunk/includes/public/class-layout.php
r3032621 r3036977 6 6 { 7 7 public $post_meta = null; 8 private $option_name = 'kitab_layout_settings'; 9 private $selected_layout_position; 10 private $selected_show_fields; 11 private $selected_show_thumbnail; 12 private $selected_display_as; 13 private $show_font_awesome; 14 15 16 8 17 /** 9 18 * Constructor to initialize the plugin. … … 15 24 // get is_post_type_allowed from PostMeta class with Kitab namespace 16 25 $this->post_meta = new PostMeta(); 26 // get options 27 $this->get_options(); 17 28 18 29 // Enqueue public assets 19 30 add_action('wp_enqueue_scripts', array($this, 'enqueue_public_assets')); 31 } 32 33 private function get_options() 34 { 35 $this->selected_layout_position = isset(get_option($this->option_name)['layout_position']) ? get_option($this->option_name)['layout_position'] : ''; 36 $this->selected_show_fields = isset(get_option($this->option_name)['show_fields']) ? get_option($this->option_name)['show_fields'] : ''; 37 $this->selected_show_thumbnail = isset(get_option($this->option_name)['show_thumbnail']); 38 $this->selected_display_as = isset(get_option($this->option_name)['display_as']) ? get_option($this->option_name)['display_as'] : ''; 39 $this->show_font_awesome = isset(get_option($this->option_name)['show_font_awesome']); 20 40 } 21 41 … … 26 46 // Check if the post type is 'book' 27 47 if ($this->post_meta->is_post_type_allowed($post_id) && !empty($book_name)) { 28 $selected_layout_position = isset(get_option('kitab_layout_settings')['layout_position']) ? get_option('kitab_layout_settings')['layout_position'] : '';29 $selected_show_fields = isset(get_option('kitab_layout_settings')['show_fields']) ? get_option('kitab_layout_settings')['show_fields'] : '';30 48 // show_thumbnail option checkbox is enabled 31 $selected_show_thumbnail = isset(get_option('kitab_layout_settings')['show_thumbnail']);32 49 33 50 // filter before book info … … 38 55 39 56 $html .= '<table class="kitab-book-fields">'; 40 57 // if selected_show_fields is array 58 if (!is_array($this->selected_show_fields)) { 59 return; 60 } 41 61 // Output HTML fields using a loop 42 62 foreach ($this->post_meta->get_book_fields() as $field_key => $field_details) { 43 63 // Check if the field is in selected_show_fields 44 if (!in_array($field_key, $ selected_show_fields)) {64 if (!in_array($field_key, $this->selected_show_fields)) { 45 65 continue; 46 66 } … … 48 68 $label = $field_details['label']; 49 69 $emoji = $field_details['emoji']; 70 $font_awesome = $field_details['fontawesome']; 71 // if font_awesome is enabled and show_font_awesome option, $icon = $font_awesome i with class else $icon = $emoji 72 $icon = $this->show_font_awesome && $font_awesome ? "<i class='{$font_awesome}'></i>" : $emoji; 73 50 74 51 75 // Allow changing the value of the field using a dynamic filter based on field name … … 55 79 // Check if the field has a value before displaying it 56 80 if (!empty($value)) { 57 $html .= "<tr class='{$field_key}'><th>{$ emoji} {$label}</th><td>";81 $html .= "<tr class='{$field_key}'><th>{$icon} {$label}</th><td>"; 58 82 59 83 // Display URL fields as clickable links … … 80 104 // $html .= apply_filters("kitab_field_{$field_key}_html", esc_html__($value)); 81 105 } else { 82 esc_html(sprintf(__('%s', 'kitab'), $value));106 $html .= esc_html(sprintf(__('%s', 'kitab'), $value)); 83 107 } 84 108 … … 92 116 93 117 // Get the post thumbnail (book cover) 94 if (has_post_thumbnail($post_id) && $ selected_show_thumbnail) {118 if (has_post_thumbnail($post_id) && $this->selected_show_thumbnail) { 95 119 $thumbnail = get_the_post_thumbnail($post_id, 'medium', array('class' => 'kitab-book-thumbnail')); 96 120 $html .= $thumbnail; … … 111 135 // Check if the post type is 'book' 112 136 if ($this->post_meta->is_post_type_allowed($post_id) && !empty($book_name)) { 113 $selected_layout_position = isset(get_option('kitab_layout_settings')['layout_position']) ? get_option('kitab_layout_settings')['layout_position'] : ''; 114 $selected_show_fields = isset(get_option('kitab_layout_settings')['show_fields']) ? get_option('kitab_layout_settings')['show_fields'] : ''; 115 // show_thumbnail option checkbox is enabled 116 $selected_show_thumbnail = isset(get_option('kitab_layout_settings')['show_thumbnail']); 137 117 138 // filter before book info 118 139 $html .= apply_filters('kitab_before_book_info', ''); … … 121 142 $html .= '<dl class="kitab-book-fields">'; 122 143 // if selected_show_fields is array 123 if (!is_array($ selected_show_fields)) {144 if (!is_array($this->selected_show_fields)) { 124 145 return; 125 146 } … … 127 148 foreach ($this->post_meta->get_book_fields() as $field_key => $field_details) { 128 149 // Check if the field is in selected_show_fields 129 if (!in_array($field_key, $ selected_show_fields)) {150 if (!in_array($field_key, $this->selected_show_fields)) { 130 151 continue; 131 152 } … … 133 154 $label = $field_details['label']; 134 155 $emoji = $field_details['emoji']; 156 $font_awesome = $field_details['fontawesome']; 157 // if font_awesome is enabled and show_font_awesome option, $icon = $font_awesome i with class else $icon = $emoji 158 $icon = $this->show_font_awesome && $font_awesome ? "<i class='{$font_awesome}'></i>" : $emoji; 159 135 160 136 161 // Allow changing the value of the field using a dynamic filter based on field name … … 141 166 if (!empty($value)) { 142 167 $html .= "<div class='{$field_key}'>"; 143 $html .= "<dt>{$ emoji} {$label}</dt><dd>";168 $html .= "<dt>{$icon} {$label}</dt><dd>"; 144 169 145 170 // Display URL fields as clickable links … … 173 198 174 199 // Get the post thumbnail (book cover) 175 if (has_post_thumbnail($post_id) && $ selected_show_thumbnail) {200 if (has_post_thumbnail($post_id) && $this->selected_show_thumbnail) { 176 201 $thumbnail = get_the_post_thumbnail($post_id, 'medium', array('class' => 'kitab-book-thumbnail')); 177 202 $html .= $thumbnail; … … 196 221 // Get the book fields HTML 197 222 // show table or dl based on display_as option 198 $fields_html = get_option('kitab_layout_settings')['display_as']=== 'table' ? $this->get_book_fields_table_html($post->ID) : $this->get_book_fields_html($post->ID);223 $fields_html = $this->selected_display_as === 'table' ? $this->get_book_fields_table_html($post->ID) : $this->get_book_fields_html($post->ID); 199 224 // Add the wrapper div to the content 200 225 // $content .= $ads . $fields_html . $ads; 201 $selected_layout_position = isset(get_option('kitab_layout_settings')['layout_position']) ? get_option('kitab_layout_settings')['layout_position'] : ''; 202 203 switch ($selected_layout_position) { 226 227 switch ($this->selected_layout_position) { 204 228 case 'above': 205 229 return $fields_html . $content; -
kitab/trunk/kitab.php
r3032621 r3036977 2 2 3 3 /** 4 * Plugin Name: Kitab 4 * Plugin Name: Kitab - Books Management System 5 5 * Description: Enhance your WordPress website with custom book functionality, including post types, meta, taxonomies, and options. 6 * Version: 1.0 6 * Version: 1.0.1 7 7 * Author: Jlil 8 8 * Author URI: https://jlil.net -
kitab/trunk/readme.txt
r3032621 r3036977 2 2 === Kitab === 3 3 Contributors: jlil 4 Tags: kitab, book, library, custom post types, taxonomies, custom fields4 Tags: kitab, book, author, library, custom post types, taxonomies, custom fields 5 5 Requires at least: 4.7 6 Tested up to: 6. 37 Stable tag: 1.0 8 Requires PHP: 7.06 Tested up to: 6.4 7 Stable tag: 1.0.1 8 Requires PHP: 8.0 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html 11 11 12 12 13 Kitab - Books Management for WordPress13 Kitab - Books Management System for WordPress 14 14 15 15 == Description == … … 17 17 18 18 == Features == 19 - Custom post type for books 20 - Custom taxonomies for authors and publishers 21 - Custom fields for books, such as ISBN, number of pages, and edition 22 - Full control over which custom fields to display and how to display them 23 - Option to choose between dl and table formats for displaying book info 19 - Custom post type for books. [todo] 20 - Custom taxonomies for authors and publishers. [todo] 21 - Custom fields for books, such as ISBN, number of pages, and edition. 22 - Full control over which custom fields to display and how to display them. 23 - Option to choose between dl and table formats for displaying book info. 24 24 25 25 == Installation == … … 37 37 == Changelog == 38 38 39 === 1.0.1 === 40 - Some minor fixes and improvements 39 41 === 1.0.0 === 40 42 - Initial release.
Note: See TracChangeset
for help on using the changeset viewer.