Plugin Directory

Changeset 3460924


Ignore:
Timestamp:
02/13/2026 04:55:47 PM (6 weeks ago)
Author:
husobj
Message:

Version 2.0

Location:
faqz/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • faqz/trunk/faqz.php

    r3460870 r3460924  
    55Plugin URI: https://github.com/benhuson/FAQz
    66Description: Simple management of Frequently Asked Questions (FAQ) via post type and categories.
    7 Version: 1.0
    8 Requires at least: 3.5
     7Version: 2.0
     8Requires at least: 4.7
    99Requires PHP: 7.4
    1010Author: Ben Huson
     
    5858        add_action( 'template_redirect', array( $this, 'template_redirect' ) );
    5959        add_filter( 'post_updated_messages', array( $this, 'post_updated_messages' ) );
    60         add_filter( 'cmspo_post_types', array( $this, 'cmspo_post_types' ) );
    61         add_shortcode( 'faqz', array( $this, 'shortcode_faqz' ) );
     60        add_shortcode( 'faqs', array( $this, 'shortcode_faqs' ) );
    6261
    6362    }
     
    9089            'query_var'          => true,
    9190            'rewrite'            => array(
    92                 'slug'       => _x( 'faqz', 'Single URL slug', 'faqz' ),
     91                'slug'       => _x( 'faqs', 'Single URL slug', 'faqz' ),
    9392                'with_front' => false
    9493            ),
     
    9897            'menu_position'      => null,
    9998            'menu_icon'          => 'dashicons-format-chat',
    100             'supports'           => array( 'title', 'editor', 'author', 'excerpt' )
     99            'supports'           => array( 'title', 'editor', 'author', 'page-attributes' )
    101100        );
    102101
    103         register_post_type( 'faqz', apply_filters( 'faqz_register_post_type_args', $args ) );
     102        register_post_type( $this->get_registered_post_type(), $args );
    104103
    105104    }
     
    113112            'hierarchical'      => true,
    114113            'labels'            => array(
    115                 'name'              => _x( 'Categories', 'taxonomy general name', 'faqz' ),
    116                 'singular_name'     => _x( 'Category', 'taxonomy singular name', 'faqz' ),
    117                 'search_items'      => __( 'Search Categories', 'faqz' ),
    118                 'all_items'         => __( 'All Categories', 'faqz' ),
    119                 'parent_item'       => __( 'Parent Category', 'faqz' ),
    120                 'parent_item_colon' => __( 'Parent Category:', 'faqz' ),
    121                 'edit_item'         => __( 'Edit Category', 'faqz' ),
    122                 'update_item'       => __( 'Update Category', 'faqz' ),
    123                 'add_new_item'      => __( 'Add New Category', 'faqz' ),
    124                 'new_item_name'     => __( 'New Category Name', 'faqz' ),
    125                 'menu_name'         => __( 'Category', 'faqz' ),
     114                'name'              => _x( 'FAQ Categories', 'taxonomy general name', 'faqz' ),
     115                'singular_name'     => _x( 'FAQ Category', 'taxonomy singular name', 'faqz' ),
     116                'search_items'      => __( 'Search FAQ Categories', 'faqz' ),
     117                'all_items'         => __( 'All FAQ Categories', 'faqz' ),
     118                'parent_item'       => __( 'Parent FAQ Category', 'faqz' ),
     119                'parent_item_colon' => __( 'Parent FAQ Category:', 'faqz' ),
     120                'edit_item'         => __( 'Edit FAQ Category', 'faqz' ),
     121                'update_item'       => __( 'Update FAQ Category', 'faqz' ),
     122                'add_new_item'      => __( 'Add New FAQ Category', 'faqz' ),
     123                'new_item_name'     => __( 'New FAQ Category Name', 'faqz' ),
     124                'menu_name'         => __( 'Categories', 'faqz' ),
    126125            ),
    127126            'public'            => true,
     
    130129            'query_var'         => true,
    131130            'rewrite'           => array(
    132                 'slug'       => 'faqz-category',
     131                'slug'       => 'faq-category',
    133132                'with_front' => false
    134133            ),
    135134        );
    136135
    137         register_taxonomy( 'faqz_category', array( 'faqz' ), apply_filters( 'faqz_register_taxonomy_args', $args ) );
     136        register_taxonomy( $this->get_registered_taxonomy(), array( $this->get_registered_post_type() ), $args );
    138137
    139138    }
     
    176175
    177176    /**
    178      * Support for CMS Page Order plugin
    179      * http://wordpress.org/extend/plugins/cms-page-order/
    180      *
    181      * @param   array  $post_types  Exisiting post type support.
    182      * @return  array               Updated post type support.
    183      */
    184     function cmspo_post_types( $post_types ) {
    185 
    186         $post_types[] = 'faqz';
    187         return $post_types;
     177     * Get Registered Post Type
     178     *
     179     * @return  string
     180     */
     181    public function get_registered_post_type() {
     182
     183        return sanitize_key( apply_filters( 'faqz_registered_post_type', 'faq' ) );
     184
     185    }
     186
     187    /**
     188     * Get Registered Taxonomy
     189     *
     190     * @return  string
     191     */
     192    public function get_registered_taxonomy() {
     193
     194        return sanitize_key( apply_filters( 'faqz_registered_taxonomy', 'faq_category' ) );
    188195
    189196    }
     
    194201    public function template_redirect() {
    195202
    196         if ( is_search() && ( is_post_type_archive( 'faqz' ) || ( is_archive() && 'faqz' == get_post_type() ) ) ) {
    197 
    198             $search_template = locate_template( 'search-faqz.php' );
     203        if ( is_search() && ( is_post_type_archive( 'faq' ) || ( is_archive() && 'faq' == get_post_type() ) ) ) {
     204
     205            $search_template = locate_template( 'search-faq.php' );
    199206
    200207            if ( '' != $search_template ) {
     
    217224        do_action( 'faqz_get_search_form' );
    218225
    219         $search_form_template = locate_template( 'searchform-faqz.php' );
    220         if ( '' != $search_form_template ) {
     226        $search_form_template = locate_template( 'searchform-faq.php' );
     227        if ( '' !== $search_form_template ) {
    221228            require( $search_form_template );
    222229            return;
    223230        }
    224231
    225         $form = '<form role="search" method="get" id="faqz-searchform" action="' . esc_url( get_post_type_archive_link( 'faqz' ) ) . '" >
    226         <div><label class="screen-reader-text" for="faqz-s">' . __( 'Search for:', 'faqz' ) . '</label>
    227         <input type="text" value="' . get_search_query() . '" name="s" id="faqz-s" />
    228         <input type="submit" id="faqz-searchsubmit" value="'. esc_attr__( 'Search', 'faqz' ) .'" />
     232        $form = '<form role="search" method="get" id="faq-searchform" class="faq-searchform" action="' . esc_url( get_post_type_archive_link( 'faq' ) ) . '" >
     233        <div><label class="screen-reader-text" for="faq-searchform-s">' . __( 'Search for:', 'faqz' ) . '</label>
     234        <input type="text" value="' . esc_attr( get_search_query() ) . '" name="s" id="faq-searchform-s" />
     235        <input type="submit" id="faq-searchform-submit" value="'. esc_attr__( 'Search', 'faqz' ) .'" />
    229236        </div>
    230237        </form>';
     
    241248
    242249    /**
    243      * Shortcode: [faq /]
     250     * Shortcode: [faqs /]
    244251     *
    245252     * @param   array   $atts     Shortcode attributes.
     
    247254     * @return  string            Content.
    248255     */
    249     public function shortcode_faqz( $atts, $content = '' ) {
    250 
    251         $atts = wp_parse_args( $atts, array(
    252             'faqz_context' => 'shortcode'
    253         ) );
     256    public function shortcode_faqs( $atts, $content = '', $shortcode_tag = '' ) {
     257
     258        $atts = wp_parse_args( $atts, array() );
    254259
    255260        return $content . $this->faqz_list( $atts );
     
    270275            'orderby'          => 'menu_order',
    271276            'order'            => 'ASC',
    272             'faqz_context'     => 'list',
    273             'faqz_before'      => '<div class="faqz-faqs">',
     277            'faqz_before'      => '<div class="faqs">',
    274278            'faqz_after'       => '</div>',
    275             'faqz_before_item' => '<div class="faqz-faq">',
     279            'faqz_before_item' => '<div class="faq">',
    276280            'faqz_after_item'  => '</div>'
    277281        ) );
    278         $args['post_type'] = 'faqz';
     282        $args['post_type'] = $this->get_registered_post_type();
    279283
    280284        $faqs = '';
     
    286290                $faqs_query->the_post();
    287291
    288                 $faq = '<h3 class="faqz-question"><a href="' . get_permalink() . '">' . get_the_title() . '</a></h3>';
    289                 $faq .= '<div class="faqz-answer">' . get_the_content() . '</div>';
     292                $faq = '<h3 class="faq__question"><a href="' . get_permalink() . '">' . get_the_title() . '</a></h3>';
     293                $faq .= '<div class="faq__answer">' . get_the_content() . '</div>';
    290294                $faqs .= $args['faqz_before_item'] . apply_filters( 'faqz_loop', $faq, $args ) . $args['faqz_after_item'];
    291295
  • faqz/trunk/includes/widgets.php

    r3460870 r3460924  
    1414
    1515        $widget_ops = array(
    16             'classname'   => 'faqz-widget-search',
     16            'classname'   => 'faq-widget-search',
    1717            'description' => __( 'An FAQ search form', 'faqz' )
    1818        );
  • faqz/trunk/languages/faqz.pot

    r3460870 r3460924  
    33msgstr ""
    44"Project-Id-Version: FAQs\n"
    5 "POT-Creation-Date: 2026-02-13 14:22+0000\n"
     5"POT-Creation-Date: 2026-02-13 16:54+0000\n"
    66"PO-Revision-Date: 2012-10-11 07:02-0000\n"
    77"Last-Translator: Ben Huson <ben@thewhiteroom.net>\n"
     
    1919"X-Poedit-SearchPath-0: ..\n"
    2020
    21 #: ../faqz.php:72 ../faqz.php:84
     21#: ../faqz.php:71 ../faqz.php:83
    2222msgid "FAQs"
    2323msgstr ""
    2424
    25 #: ../faqz.php:73
     25#: ../faqz.php:72
    2626msgid "FAQ"
    2727msgstr ""
    2828
    29 #: ../faqz.php:74
     29#: ../faqz.php:73
    3030msgid "Add New"
    3131msgstr ""
    3232
    33 #: ../faqz.php:75
     33#: ../faqz.php:74
    3434msgid "Add New FAQ"
    3535msgstr ""
    3636
    37 #: ../faqz.php:76
     37#: ../faqz.php:75
    3838msgid "Edit FAQ"
    3939msgstr ""
    4040
    41 #: ../faqz.php:77
     41#: ../faqz.php:76
    4242msgid "New FAQ"
    4343msgstr ""
    4444
    45 #: ../faqz.php:78
     45#: ../faqz.php:77
    4646msgid "All FAQs"
    4747msgstr ""
    4848
    49 #: ../faqz.php:79
     49#: ../faqz.php:78
    5050msgid "View FAQ"
    5151msgstr ""
    5252
    53 #: ../faqz.php:80
     53#: ../faqz.php:79
    5454msgid "Search FAQs"
    5555msgstr ""
    5656
    57 #: ../faqz.php:81
     57#: ../faqz.php:80
    5858msgid "No FAQs found"
    5959msgstr ""
    6060
    61 #: ../faqz.php:82
     61#: ../faqz.php:81
    6262msgid "No FAQs found in Trash"
    6363msgstr ""
    6464
    65 #: ../faqz.php:92
    66 msgid "faqz"
     65#: ../faqz.php:91
     66msgid "faqs"
     67msgstr ""
     68
     69#: ../faqz.php:114
     70msgid "FAQ Categories"
    6771msgstr ""
    6872
    6973#: ../faqz.php:115
     74msgid "FAQ Category"
     75msgstr ""
     76
     77#: ../faqz.php:116
     78msgid "Search FAQ Categories"
     79msgstr ""
     80
     81#: ../faqz.php:117
     82msgid "All FAQ Categories"
     83msgstr ""
     84
     85#: ../faqz.php:118
     86msgid "Parent FAQ Category"
     87msgstr ""
     88
     89#: ../faqz.php:119
     90msgid "Parent FAQ Category:"
     91msgstr ""
     92
     93#: ../faqz.php:120
     94msgid "Edit FAQ Category"
     95msgstr ""
     96
     97#: ../faqz.php:121
     98msgid "Update FAQ Category"
     99msgstr ""
     100
     101#: ../faqz.php:122
     102msgid "Add New FAQ Category"
     103msgstr ""
     104
     105#: ../faqz.php:123
     106msgid "New FAQ Category Name"
     107msgstr ""
     108
     109#: ../faqz.php:124
    70110msgid "Categories"
    71111msgstr ""
    72112
    73 #: ../faqz.php:116 ../faqz.php:125
    74 msgid "Category"
    75 msgstr ""
    76 
    77 #: ../faqz.php:117
    78 msgid "Search Categories"
    79 msgstr ""
    80 
    81 #: ../faqz.php:118
    82 msgid "All Categories"
    83 msgstr ""
    84 
    85 #: ../faqz.php:119
    86 msgid "Parent Category"
    87 msgstr ""
    88 
    89 #: ../faqz.php:120
    90 msgid "Parent Category:"
    91 msgstr ""
    92 
    93 #: ../faqz.php:121
    94 msgid "Edit Category"
    95 msgstr ""
    96 
    97 #: ../faqz.php:122
    98 msgid "Update Category"
    99 msgstr ""
    100 
    101 #: ../faqz.php:123
    102 msgid "Add New Category"
    103 msgstr ""
    104 
    105 #: ../faqz.php:124
    106 msgid "New Category Name"
    107 msgstr ""
    108 
    109 #: ../faqz.php:154
     113#: ../faqz.php:153
    110114#, php-format
    111115msgid "FAQ updated. <a href=\"%s\">View FAQ</a>"
    112116msgstr ""
    113117
    114 #: ../faqz.php:155
     118#: ../faqz.php:154
    115119msgid "Custom field updated."
    116120msgstr ""
    117121
    118 #: ../faqz.php:156
     122#: ../faqz.php:155
    119123msgid "Custom field deleted."
    120124msgstr ""
    121125
    122 #: ../faqz.php:157
     126#: ../faqz.php:156
    123127msgid "FAQ updated."
    124128msgstr ""
    125129
    126 #: ../faqz.php:159
     130#: ../faqz.php:158
    127131#, php-format
    128132msgid "FAQ restored to revision from %s"
    129133msgstr ""
    130134
    131 #: ../faqz.php:161
     135#: ../faqz.php:160
    132136#, php-format
    133137msgid "FAQ published. <a href=\"%s\">View FAQ</a>"
    134138msgstr ""
    135139
    136 #: ../faqz.php:162
     140#: ../faqz.php:161
    137141msgid "FAQ saved."
    138142msgstr ""
    139143
    140 #: ../faqz.php:164
     144#: ../faqz.php:163
    141145#, php-format
    142146msgid "FAQ submitted. <a target=\"_blank\" href=\"%s\">Preview FAQ</a>"
    143147msgstr ""
    144148
    145 #: ../faqz.php:166
     149#: ../faqz.php:165
    146150#, php-format
    147151msgid ""
     
    150154msgstr ""
    151155
    152 #: ../faqz.php:168
     156#: ../faqz.php:167
    153157msgid "M j, Y @ G:i"
    154158msgstr ""
    155159
    156 #: ../faqz.php:170
     160#: ../faqz.php:169
    157161#, php-format
    158162msgid "FAQ draft updated. <a target=\"_blank\" href=\"%s\">Preview FAQ</a>"
    159163msgstr ""
    160164
    161 #: ../faqz.php:226
     165#: ../faqz.php:233
    162166msgid "Search for:"
    163167msgstr ""
    164168
    165 #: ../faqz.php:228
     169#: ../faqz.php:235
    166170msgid "Search"
    167171msgstr ""
  • faqz/trunk/readme.txt

    r3460873 r3460924  
    33Donate link: https://www.paypal.com/ncp/payment/P64UGJHU5MZVE
    44Tags: faq, faqs, questions, answers, knowledgebase
    5 Requires at least: 3.5
     5Requires at least: 4.7
    66Tested up to: 6.9
    7 Stable tag: 1.0
     7Stable tag: 2.0
    88Requires PHP: 7.4
    99License: GPLv2 or later
     
    1818It consists of:
    1919
    20 * A simple 'faqz' post type
    21 * [faqz /] shortcode
     20* A simple 'faq' post type
     21* [faqs /] shortcode
    2222* FAQ search widget
    2323* FAQ search form template tag
     
    3434This is just a first release. More to come...
    3535
     36= Why so many breaking changes in version 2.0? =
     37
     38The main post type was changed to `faq` so the plugin is easier to migrate to/from other FAQ plugins. Front end CSS classes were changed to reflect this and follow a more predictable BEM format. Code and plugin hooks retained their `faqz` namespace. It is possible to reinstate some backward compatibility using the filters mentioned in the changelog and updating your template names and CSS files.
     39
    3640== Screenshots ==
    3741
     
    4044
    4145== Changelog ==
     46
     47= 2.0 =
     48* Breaking Change: Post type `faqz` is now `faq`. Use `faqz_registered_post_type` filter for backwards compatibility.
     49* Breaking Change: Taxonomy `faqz-category` is now `faq-category`. Use `faqz_registered_taxonomy` filter for backwards compatibility.
     50* Breaking Change: Post type single and archive URL slug is now `faqs` instead of `faqz`. Use `register_faq_post_type_args` filter to change.
     51* Breaking Change: Category URL slug is now `faq-category` instead of `faqz-category`. Use `register_faq-category_taxonomy_args` filter to change.
     52* Breaking Change: `faqz` shortcode is now `faqs`.
     53* Breaking Change: Removed `faqz_register_post_type_args` filter. Use `register_faq_post_type_args`.
     54* Breaking Change: Removed `faqz_register_taxonomy_args` filter. Use `register_faq-category_taxonomy_args`.
     55* Breaking Change: Optional template `search-faq.php` changed to `search-faqz.php`.
     56* Breaking Change: Optional template `searchform-faqz.php` changed to `searchform-faq.php`.
     57* Breaking Change: `faqz_context` arg removed from faqz_list() display method.
     58* Breaking Change: CSS classes for search form and default FAQs output changed.
    4259
    4360= 1.0 =
Note: See TracChangeset for help on using the changeset viewer.