Plugin Directory

Changeset 3036977


Ignore:
Timestamp:
02/16/2024 08:31:29 PM (2 years ago)
Author:
jlil
Message:

Some minor fixes and improvements

Location:
kitab/trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • kitab/trunk/includes/classes/class-postmeta.php

    r3032621 r3036977  
    124124                'dashicon' => 'dashicons-book',
    125125                'emoji' => '📚',
     126                'fontawesome' => 'fas fa-book',
    126127                'description' => esc_html__('Enter the name of the book', 'kitab'),
    127128                'priority' => 10
     
    133134                'dashicon' => 'dashicons-admin-users',
    134135                'emoji' => '👨‍🏫',
     136                'fontawesome' => 'fas fa-user',
    135137                'description' => esc_html__('Enter the name of the author', 'kitab'),
    136138                'priority' => 11
     
    141143                'dashicon' => 'dashicons-admin-links',
    142144                'emoji' => '📄',
     145                'fontawesome' => 'fas fa-file',
    143146                'description' => esc_html__('Enter the number of pages in the book', 'kitab'),
    144147                'priority' => 20
     
    149152                'dashicon' => 'dashicons-clipboard',
    150153                'emoji' => '📑',
     154                'fontawesome' => 'fas fa-clipboard',
    151155                'description' => esc_html__('Enter the edition of the book', 'kitab'),
    152156                'priority' => 30
     
    157161                'dashicon' => 'dashicons-tag',
    158162                'emoji' => '🏷️',
     163                'fontawesome' => 'fas fa-tag',
    159164                'description' => esc_html__('Enter the ISBN of the book', 'kitab'),
    160165                'priority' => 40
     
    165170                'dashicon' => 'dashicons-calendar',
    166171                'emoji' => '📅',
     172                'fontawesome' => 'fas fa-calendar',
    167173                'description' => esc_html__('Enter the year of copyright', 'kitab'),
    168174                'priority' => 50
     
    173179                'dashicon' => 'dashicons-businessman',
    174180                'emoji' => '👨‍💼',
     181                'fontawesome' => 'fas fa-user-tie',
    175182                'description' => esc_html__('Enter the name of the copyright holder', 'kitab'),
    176183                'priority' => 60
     
    181188                'dashicon' => 'dashicons-download',
    182189                'emoji' => '📥',
     190                'fontawesome' => 'fas fa-download',
    183191                'description' => esc_html__('Enter the URL of the PDF download link', 'kitab'),
    184192                'priority' => 70
     
    189197                'dashicon' => 'dashicons-media-archive',
    190198                'emoji' => '📦',
     199                'fontawesome' => 'fas fa-archive',
    191200                'description' => esc_html__('Enter the URL of the EPUB download link', 'kitab'),
    192201                'priority' => 80
     
    197206                'dashicon' => 'dashicons-cart',
    198207                'emoji' => '🛒',
     208                'fontawesome' => 'fas fa-shopping-cart',
    199209                'description' => esc_html__('Enter the URL of the buy link', 'kitab'),
    200210                'priority' => 90
  • kitab/trunk/includes/classes/options-tabs/layout-options.php

    r3032621 r3036977  
    6565                    </td>
    6666                </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>
    6784                <tr>
    6885                    <th scope="row"><?php esc_html_e('Disable Downloads in Copyrighted Claims Books', 'kitab'); ?></th>
  • kitab/trunk/includes/public/class-layout.php

    r3032621 r3036977  
    66{
    77    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
    817    /**
    918     * Constructor to initialize the plugin.
     
    1524        // get is_post_type_allowed from PostMeta class with Kitab namespace
    1625        $this->post_meta = new PostMeta();
     26        // get options
     27        $this->get_options();
    1728
    1829        // Enqueue public assets
    1930        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']);
    2040    }
    2141
     
    2646        // Check if the post type is 'book'
    2747        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'] : '';
    3048            // show_thumbnail option checkbox is enabled
    31             $selected_show_thumbnail = isset(get_option('kitab_layout_settings')['show_thumbnail']);
    3249
    3350            // filter before book info
     
    3855
    3956            $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            }
    4161            // Output HTML fields using a loop
    4262            foreach ($this->post_meta->get_book_fields() as $field_key => $field_details) {
    4363                // 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)) {
    4565                    continue;
    4666                }
     
    4868                $label = $field_details['label'];
    4969                $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
    5074
    5175                // Allow changing the value of the field using a dynamic filter based on field name
     
    5579                // Check if the field has a value before displaying it
    5680                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>";
    5882
    5983                    // Display URL fields as clickable links
     
    80104                        // $html .= apply_filters("kitab_field_{$field_key}_html", esc_html__($value));
    81105                    } else {
    82                         esc_html(sprintf(__('%s', 'kitab'), $value));
     106                        $html .= esc_html(sprintf(__('%s', 'kitab'), $value));
    83107                    }
    84108
     
    92116
    93117            // 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) {
    95119                $thumbnail = get_the_post_thumbnail($post_id, 'medium', array('class' => 'kitab-book-thumbnail'));
    96120                $html .= $thumbnail;
     
    111135        // Check if the post type is 'book'
    112136        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
    117138            // filter before book info
    118139            $html .= apply_filters('kitab_before_book_info', '');
     
    121142            $html .= '<dl class="kitab-book-fields">';
    122143            // if selected_show_fields is array
    123             if (!is_array($selected_show_fields)) {
     144            if (!is_array($this->selected_show_fields)) {
    124145                return;
    125146            }
     
    127148            foreach ($this->post_meta->get_book_fields() as $field_key => $field_details) {
    128149                // 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)) {
    130151                    continue;
    131152                }
     
    133154                $label = $field_details['label'];
    134155                $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
    135160
    136161                // Allow changing the value of the field using a dynamic filter based on field name
     
    141166                if (!empty($value)) {
    142167                    $html .= "<div class='{$field_key}'>";
    143                     $html .= "<dt>{$emoji} {$label}</dt><dd>";
     168                    $html .= "<dt>{$icon} {$label}</dt><dd>";
    144169
    145170                    // Display URL fields as clickable links
     
    173198
    174199            // 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) {
    176201                $thumbnail = get_the_post_thumbnail($post_id, 'medium', array('class' => 'kitab-book-thumbnail'));
    177202                $html .= $thumbnail;
     
    196221            // Get the book fields HTML
    197222            // 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);
    199224            // Add the wrapper div to the content
    200225            // $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) {
    204228                case 'above':
    205229                    return $fields_html . $content;
  • kitab/trunk/kitab.php

    r3032621 r3036977  
    22
    33/**
    4  * Plugin Name: Kitab
     4 * Plugin Name: Kitab - Books Management System
    55 * 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
    77 * Author: Jlil
    88 * Author URI: https://jlil.net
  • kitab/trunk/readme.txt

    r3032621 r3036977  
    22=== Kitab ===
    33Contributors: jlil
    4 Tags: kitab, book, library, custom post types, taxonomies, custom fields
     4Tags: kitab, book, author, library, custom post types, taxonomies, custom fields
    55Requires at least: 4.7
    6 Tested up to: 6.3
    7 Stable tag: 1.0
    8 Requires PHP: 7.0
     6Tested up to: 6.4
     7Stable tag: 1.0.1
     8Requires PHP: 8.0
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
    1111
    1212
    13 Kitab - Books Management for WordPress
     13Kitab - Books Management System for WordPress
    1414
    1515== Description ==
     
    1717
    1818== 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.
    2424
    2525== Installation ==
     
    3737== Changelog ==
    3838
     39=== 1.0.1 ===
     40- Some minor fixes and improvements
    3941=== 1.0.0 ===
    4042- Initial release.
Note: See TracChangeset for help on using the changeset viewer.