Plugin Directory

Changeset 3277788


Ignore:
Timestamp:
04/21/2025 01:13:55 AM (8 months ago)
Author:
daisyplugins
Message:

v1.0.3

Location:
daisy-titles
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • daisy-titles/trunk/daisy-titles.php

    r3277701 r3277788  
    33 * Plugin Name:         Daisy Titles
    44 * Plugin URI:          https://wordpress.org/plugins/daisy-titles
    5  * Description:         Customize titles with colors, sizes, and fonts.
    6  * Version:             1.0.2
     5 * Description:        Customize titles with colors, sizes, and fonts. Hide titles on posts and pages.
     6 * Version:             1.0.3
    77 * Requires at least:   5.2
    88 * Requires PHP:        7.2
     
    1818    exit;
    1919}
     20
     21// Define constants
     22define('DAISY_TITLES_VERSION', '1.0.3');
     23define('DAISY_TITLES_PLUGIN_URL', plugin_dir_url(__FILE__));
     24define('DAISY_TITLES_PLUGIN_PATH', plugin_dir_path(__FILE__));
    2025
    2126// Add settings page to the admin menu
     
    4348    );
    4449
     50
     51
     52    // Title visibility section
     53    add_settings_section(
     54        'daisy_titles_visibility_section',
     55        __('Title Visibility Options', 'daisy-titles'),
     56        'daisy_titles_visibility_section_callback',
     57        'daisy_titles_plugin'
     58    );
     59
     60    // Hide all posts titles
     61    add_settings_field(
     62        'daisy_titles_hide_all_posts',
     63        __('Hide Titles on All Posts', 'daisy-titles'),
     64        'daisy_titles_hide_all_posts_render',
     65        'daisy_titles_plugin',
     66        'daisy_titles_visibility_section'
     67    );
     68
     69    // Hide all pages titles
     70    add_settings_field(
     71        'daisy_titles_hide_all_pages',
     72        __('Hide Titles on All Pages', 'daisy-titles'),
     73        'daisy_titles_hide_all_pages_render',
     74        'daisy_titles_plugin',
     75        'daisy_titles_visibility_section'
     76    );
     77
     78
     79
     80
     81    // Main settings section
    4582    add_settings_section(
    4683        'daisy_titles_main_section',
    47         __('Daisy Titles Options', 'daisy-titles'),
     84        __('<hr><br>Title Styling Options', 'daisy-titles'),
    4885        'daisy_titles_section_callback',
    4986        'daisy_titles_plugin'
     
    85122        'daisy_titles_main_section'
    86123    );
     124
     125
    87126}
    88127
     
    90129function daisy_titles_section_callback() {
    91130    esc_html_e('Customize how your post titles appear on the front-end.', 'daisy-titles');
     131}
     132
     133// Visibility section callback
     134function daisy_titles_visibility_section_callback() {
     135    esc_html_e('Control the visibility of titles globally. Individual post settings will override these options.', 'daisy-titles');
    92136}
    93137
     
    148192}
    149193
     194// Hide all posts titles render
     195function daisy_titles_hide_all_posts_render() {
     196    $options = get_option('daisy_titles_settings');
     197    ?>
     198    <label class="daisy-switch">
     199        <input type="checkbox" name="daisy_titles_settings[daisy_titles_hide_all_posts]" value="1" <?php checked(isset($options['daisy_titles_hide_all_posts']) && $options['daisy_titles_hide_all_posts']); ?>>
     200        <span class="daisy-slider daisy-round"></span>
     201    </label>
     202    <?php
     203}
     204
     205// Hide all pages titles render
     206function daisy_titles_hide_all_pages_render() {
     207    $options = get_option('daisy_titles_settings');
     208    ?>
     209    <label class="daisy-switch">
     210        <input type="checkbox" name="daisy_titles_settings[daisy_titles_hide_all_pages]" value="1" <?php checked(isset($options['daisy_titles_hide_all_pages']) && $options['daisy_titles_hide_all_pages']); ?>>
     211        <span class="daisy-slider daisy-round"></span>
     212    </label>
     213    <?php
     214}
     215
    150216// Options page
    151217function daisy_titles_options_page() {
     
    155221    }
    156222    ?>
    157     <div class="wrap">
    158         <h1><?php echo esc_html(get_admin_page_title()); ?></h1>
    159         <form action="options.php" method="post">
    160             <?php
    161             settings_fields('daisy_titles_plugin');
    162             do_settings_sections('daisy_titles_plugin');
    163             submit_button(__('Save Settings', 'daisy-titles'));
    164             ?>
    165         </form>
     223    <div class="wrap daisy-titles-admin">
     224        <div class="daisy-header">
     225            <h1><span class="daisy-icon">🌼</span> <?php echo esc_html(get_admin_page_title()); ?></h1>
     226            <p class="daisy-description"><?php esc_html_e('Customize your titles with beautiful styles and visibility options', 'daisy-titles'); ?></p>
     227        </div>
     228       
     229        <div class="daisy-content-wrap">
     230            <div class="daisy-settings-card">
     231                <form action="options.php" method="post">
     232                    <?php
     233                    settings_fields('daisy_titles_plugin');
     234                    do_settings_sections('daisy_titles_plugin');
     235                    submit_button(__('Save Settings', 'daisy-titles'), 'primary', 'submit', false);
     236                    ?>
     237                </form>
     238            </div>
     239           
     240            <div class="daisy-sidebar">
     241                <div class="daisy-card">
     242                    <h3><?php esc_html_e('Need Help?', 'daisy-titles'); ?></h3>
     243                    <p><?php esc_html_e('Check out our documentation or contact support if you have any questions.', 'daisy-titles'); ?></p>
     244                    <a href="https://wordpress.org/support/plugin/daisy-titles/" class="button" target="_blank"><?php esc_html_e('Get Support', 'daisy-titles'); ?></a>
     245                </div>
     246               
     247                <div class="daisy-card">
     248                    <h3><?php esc_html_e('Like This Plugin?', 'daisy-titles'); ?></h3>
     249                    <p><?php esc_html_e('Please consider leaving a review on WordPress.org.', 'daisy-titles'); ?></p>
     250                    <a href="https://wordpress.org/support/plugin/daisy-titles/reviews/" class="button" target="_blank"><?php esc_html_e('Leave a Review', 'daisy-titles'); ?></a>
     251                </div>
     252            </div>
     253        </div>
    166254    </div>
    167255    <?php
     
    211299    }
    212300   
     301    // Sanitize hide all posts
     302    if (isset($new_settings['daisy_titles_hide_all_posts'])) {
     303        $sanitized['daisy_titles_hide_all_posts'] = (bool)$new_settings['daisy_titles_hide_all_posts'];
     304    }
     305   
     306    // Sanitize hide all pages
     307    if (isset($new_settings['daisy_titles_hide_all_pages'])) {
     308        $sanitized['daisy_titles_hide_all_pages'] = (bool)$new_settings['daisy_titles_hide_all_pages'];
     309    }
     310   
    213311    return $sanitized;
     312}
     313
     314// Add metabox to posts and pages
     315add_action('add_meta_boxes', 'daisy_titles_add_meta_box');
     316function daisy_titles_add_meta_box() {
     317    $post_types = get_post_types(array('public' => true));
     318   
     319    foreach ($post_types as $post_type) {
     320        if ($post_type === 'attachment') continue;
     321       
     322        add_meta_box(
     323            'daisy_titles_visibility',
     324            __('Title Visibility', 'daisy-titles'),
     325            'daisy_titles_meta_box_callback',
     326            $post_type,
     327            'side',
     328            'default'
     329        );
     330    }
     331}
     332
     333// Metabox callback
     334function daisy_titles_meta_box_callback($post) {
     335    wp_nonce_field('daisy_titles_save_meta_box_data', 'daisy_titles_meta_box_nonce');
     336   
     337    $hide_title = get_post_meta($post->ID, '_daisy_titles_hide_title', true);
     338    ?>
     339    <div class="daisy-meta-box">
     340        <label for="daisy_titles_hide_title" class="daisy-toggle-label">
     341            <?php esc_html_e('Hide Title on Single View', 'daisy-titles'); ?>
     342        </label>
     343        <label class="daisy-switch">
     344            <input type="checkbox" id="daisy_titles_hide_title" name="daisy_titles_hide_title" value="1" <?php checked($hide_title); ?>>
     345            <span class="daisy-slider daisy-round"></span>
     346        </label>
     347        <p class="description"><?php esc_html_e('This will hide the title only on the single post/page view.', 'daisy-titles'); ?></p>
     348    </div>
     349    <?php
     350}
     351
     352// Save metabox data
     353add_action('save_post', 'daisy_titles_save_meta_box_data');
     354function daisy_titles_save_meta_box_data($post_id) {
     355    // Check if our nonce is set
     356    if (!isset($_POST['daisy_titles_meta_box_nonce'])) {
     357        return;
     358    }
     359   
     360    // Verify that the nonce is valid
     361    if (!wp_verify_nonce($_POST['daisy_titles_meta_box_nonce'], 'daisy_titles_save_meta_box_data')) {
     362        return;
     363    }
     364   
     365    // If this is an autosave, our form has not been submitted, so we don't want to do anything
     366    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
     367        return;
     368    }
     369   
     370    // Check the user's permissions
     371    if (!current_user_can('edit_post', $post_id)) {
     372        return;
     373    }
     374   
     375    // Save or delete the meta field
     376    if (isset($_POST['daisy_titles_hide_title'])) {
     377        update_post_meta($post_id, '_daisy_titles_hide_title', (bool)$_POST['daisy_titles_hide_title']);
     378    } else {
     379        delete_post_meta($post_id, '_daisy_titles_hide_title');
     380    }
    214381}
    215382
     
    217384add_filter('the_title', 'daisy_titles_modify_title', 10, 2);
    218385function daisy_titles_modify_title($title, $id) {
    219     // Don't modify titles in admin area
    220     if (is_admin()) {
     386    // Don't modify titles in admin area or for nav menus
     387    if (is_admin() || doing_filter('wp_nav_menu_objects')) {
    221388        return $title;
    222389    }
    223390   
     391    // Only modify titles on single posts/pages
     392    if (!is_singular()) {
     393        return $title;
     394    }
     395   
     396    $post = get_post($id);
     397    if (!$post) {
     398        return $title;
     399    }
     400   
     401    // Check if title is hidden for this post
     402    $hide_title = get_post_meta($post->ID, '_daisy_titles_hide_title', true);
     403   
     404    // Check global hide settings if not overridden by post
     405    if (!$hide_title) {
     406        $options = get_option('daisy_titles_settings');
     407       
     408        if ($post->post_type === 'post' && isset($options['daisy_titles_hide_all_posts']) && $options['daisy_titles_hide_all_posts']) {
     409            $hide_title = true;
     410        } elseif ($post->post_type === 'page' && isset($options['daisy_titles_hide_all_pages']) && $options['daisy_titles_hide_all_pages']) {
     411            $hide_title = true;
     412        }
     413    }
     414   
     415    // Return empty if title should be hidden
     416    if ($hide_title) {
     417        return '';
     418    }
     419   
     420    // Apply styling if not hidden
    224421    $options = get_option('daisy_titles_settings');
    225422    if (empty($options)) {
     
    263460    load_plugin_textdomain('daisy-titles', false, dirname(plugin_basename(__FILE__)) . '/languages/');
    264461}
     462
     463// Enqueue admin styles
     464add_action('admin_enqueue_scripts', 'daisy_titles_admin_styles');
     465function daisy_titles_admin_styles() {
     466    $screen = get_current_screen();
     467   
     468    // Only load on our settings page and post edit screens
     469    if ($screen->id === 'settings_page_daisy-titles' || $screen->base === 'post') {
     470        echo '<style>
     471        /* Daisy Titles Admin Styles */
     472        .daisy-titles-admin {
     473            max-width: 1200px;
     474        }
     475
     476        .daisy-header {
     477            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
     478            padding: 20px;
     479            border-radius: 8px;
     480            margin-bottom: 20px;
     481            border-left: 5px solid #9b59b6;
     482        }
     483
     484        .daisy-header h1 {
     485            color: #333;
     486            margin: 0;
     487            display: flex;
     488            align-items: center;
     489            font-size: 28px;
     490        }
     491
     492        .daisy-header .daisy-icon {
     493            margin-right: 10px;
     494            font-size: 32px;
     495        }
     496
     497        .daisy-header .daisy-description {
     498            margin: 5px 0 0;
     499            color: #555;
     500            font-size: 15px;
     501        }
     502
     503        .daisy-content-wrap {
     504            display: flex;
     505            gap: 20px;
     506        }
     507
     508        .daisy-settings-card {
     509            flex: 1;
     510            background: #fff;
     511            padding: 20px;
     512            border-radius: 8px;
     513            box-shadow: 0 2px 10px rgba(0,0,0,0.05);
     514        }
     515
     516        .daisy-sidebar {
     517            width: 300px;
     518        }
     519
     520        .daisy-card {
     521            background: #fff;
     522            padding: 20px;
     523            border-radius: 8px;
     524            box-shadow: 0 2px 10px rgba(0,0,0,0.05);
     525            margin-bottom: 20px;
     526        }
     527
     528        .daisy-card h3 {
     529            margin-top: 0;
     530            color: #333;
     531        }
     532
     533        .daisy-card p {
     534            color: #666;
     535            margin-bottom: 15px;
     536        }
     537
     538        /* Toggle switch styles */
     539        .daisy-switch {
     540            position: relative;
     541            display: inline-block;
     542            width: 50px;
     543            height: 24px;
     544            margin-left: 10px;
     545            vertical-align: middle;
     546        }
     547
     548        .daisy-switch input {
     549            opacity: 0;
     550            width: 0;
     551            height: 0;
     552        }
     553
     554        .daisy-slider {
     555            position: absolute;
     556            cursor: pointer;
     557            top: 0;
     558            left: 0;
     559            right: 0;
     560            bottom: 0;
     561            background-color: #ccc;
     562            transition: .4s;
     563            border-radius: 24px;
     564        }
     565
     566        .daisy-slider:before {
     567            position: absolute;
     568            content: "";
     569            height: 16px;
     570            width: 16px;
     571            left: 4px;
     572            bottom: 4px;
     573            background-color: white;
     574            transition: .4s;
     575            border-radius: 50%;
     576        }
     577
     578        input:checked + .daisy-slider {
     579            background-color: #9b59b6;
     580        }
     581
     582        input:checked + .daisy-slider:before {
     583            transform: translateX(26px);
     584        }
     585
     586        .daisy-toggle-label {
     587            display: inline-block;
     588            margin-right: 10px;
     589            vertical-align: middle;
     590            font-weight: 500;
     591        }
     592
     593        /* Meta box styles */
     594        .daisy-meta-box {
     595            padding: 10px 0;
     596        }
     597
     598        .daisy-meta-box .description {
     599            margin-top: 10px;
     600            color: #666;
     601            font-style: italic;
     602            font-size: 13px;
     603        }
     604
     605        @media (max-width: 782px) {
     606            .daisy-content-wrap {
     607                flex-direction: column;
     608            }
     609           
     610            .daisy-sidebar {
     611                width: 100%;
     612            }
     613        }
     614        </style>';
     615    }
     616}
     617
     618// Clean up on uninstallation
     619register_uninstall_hook(__FILE__, 'daisy_titles_uninstall');
     620function daisy_titles_uninstall() {
     621    // Delete plugin options
     622    delete_option('daisy_titles_settings');
     623   
     624    // Remove all post meta data created by the plugin
     625    $posts = get_posts(array(
     626        'post_type' => 'any',
     627        'post_status' => 'any',
     628        'numberposts' => -1,
     629        'meta_key' => '_daisy_titles_hide_title'
     630    ));
     631   
     632    foreach ($posts as $post) {
     633        delete_post_meta($post->ID, '_daisy_titles_hide_title');
     634    }
     635}
  • daisy-titles/trunk/readme.txt

    r3277701 r3277788  
    1 === Daisy Titles ===
     1=== Daisy Titles – Design and Hide Titles, Hide Page Titles, Hide Post Titles, Hide Page And Post Titles ===
    22Contributors: daisyplugins
    33Tags: titles, hide titles, hide post titles, hide page titles, hide page and post titles
    44Requires at least: 5.2
    55Tested up to: 6.8
    6 Stable tag: 1.0.2
     6Stable tag: 1.0.3
    77Requires PHP: 7.2
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    1010
    11 Customize the appearance of your post titles with colors, font sizes, and font families.
     11Customize the appearance of your post titles with colors, font sizes, and font families. Hide titles on posts and pages.
    1212
    1313== Description ==
     
    4848== Changelog ==
    4949
     50= 1.0.3 - Apr 21, 2025=
     51* [add] new feature: hide titles
     52* [imp] user interface
     53
    5054= 1.0.2 - Apr 20, 2025=
    5155* Second release
Note: See TracChangeset for help on using the changeset viewer.