Plugin Directory

Changeset 2940296

Timestamp:
07/19/2023 10:49:43 AM (12 months ago)
Author:
maheshpatel
Message:

Update plugin to latest version of wordpress 6.2

Location:
accordion-faq-plugin/trunk
Files:
5 added
1 edited

Legend:

Unmodified
Added
Removed
  • accordion-faq-plugin/trunk/accordion_faq.php

    r1300313 r2940296  
    22/*
    33Plugin Name: Accordion FAQ plugin
    4 Plugin URL: p.mahesh8850@gmail.com 
     4Plugin URL: p.mahesh8850@gmail.com
    55Description: Faq plugin provide you accordion with simple,easy,best,quick and multiple faq.
    6 Version:1.0.0
     6Version:2.0.0
     7Requires at least: 6.0
     8Requires PHP: 7.2
    79Author: maheshpatel
    810Author URI: p.mahesh8850@gmail.com
     
    1214
    1315// Register Custom Taxonomy
    14 function taxonomy_quick_faq() {
     16function taxonomy_quick_faq()
     17{
    1518
    1619    $labels = array(
    17         'name'                       => _x( 'Faq  Taxonomies', 'Taxonomy General Name', 'text_domain' ),
    18         'singular_name'              => _x( 'Faq Taxonomy', 'Taxonomy Singular Name', 'text_domain' ),
    19         'menu_name'                  => __( 'Quick Faq', 'text_domain' ),
    20         'all_items'                  => __( 'All Items', 'text_domain' ),
    21         'parent_item'                => __( 'Parent Item', 'text_domain' ),
    22         'parent_item_colon'          => __( 'Parent Item:', 'text_domain' ),
    23         'new_item_name'              => __( 'New Item Name', 'text_domain' ),
    24         'add_new_item'               => __( 'Add New Item', 'text_domain' ),
    25         'edit_item'                  => __( 'Edit Item', 'text_domain' ),
    26         'update_item'                => __( 'Update Item', 'text_domain' ),
    27         'view_item'                  => __( 'View Item', 'text_domain' ),
    28         'separate_items_with_commas' => __( 'Separate items with commas', 'text_domain' ),
    29         'add_or_remove_items'        => __( 'Add or remove items', 'text_domain' ),
    30         'choose_from_most_used'      => __( 'Choose from the most used', 'text_domain' ),
    31         'popular_items'              => __( 'Popular Items', 'text_domain' ),
    32         'search_items'               => __( 'Search Items', 'text_domain' ),
    33         'not_found'                  => __( 'Not Found', 'text_domain' ),
     20        'name'                       => _x(),
     21        'singular_name'              => _x(),
     22        'menu_name'                  => __(),
     23        'all_items'                  => __(),
     24        'parent_item'                => __(),
     25        'parent_item_colon'          => __(),
     26        'new_item_name'              => __(),
     27        'add_new_item'               => __(),
     28        'edit_item'                  => __(),
     29        'update_item'                => __(),
     30        'view_item'                  => __(),
     31        'separate_items_with_commas' => __(),
     32        'add_or_remove_items'        => __(),
     33        'choose_from_most_used'      => __(),
     34        'popular_items'              => __(),
     35        'search_items'               => __(),
     36        'not_found'                  => __(),
    3437    );
    3538    $args = array(
     
    4245        'show_tagcloud'              => true,
    4346    );
    44     register_taxonomy( 'quick_faq_tax', array( 'quick_faq' ), $args );
    45 
     47    register_taxonomy('quick_faq_tax', array('quick_faq'), $args);
    4648}
    47 add_action( 'init', 'taxonomy_quick_faq', 0 );
     49add_action();
    4850
    4951
    5052// Register Custom Post Type
    51 function post_quick_faq() {
     53function post_quick_faq()
     54{
    5255
    5356    $labels = array(
    54         'name'                => _x( 'Quick Faqs', 'Post Type General Name', 'text_domain' ),
    55         'singular_name'       => _x( 'Quick Faq', 'Post Type Singular Name', 'text_domain' ),
    56         'menu_name'           => __( 'Quick Faq', 'text_domain' ),
    57         'name_admin_bar'      => __( 'Quick Faq', 'text_domain' ),
    58         'parent_item_colon'   => __( 'Parent Item:', 'text_domain' ),
    59         'all_items'           => __( 'All Items', 'text_domain' ),
    60         'add_new_item'        => __( 'Add New Item', 'text_domain' ),
    61         'add_new'             => __( 'Add New', 'text_domain' ),
    62         'new_item'            => __( 'New Item', 'text_domain' ),
    63         'edit_item'           => __( 'Edit Item', 'text_domain' ),
    64         'update_item'         => __( 'Update Item', 'text_domain' ),
    65         'view_item'           => __( 'View Item', 'text_domain' ),
    66         'search_items'        => __( 'Search Item', 'text_domain' ),
    67         'not_found'           => __( 'Not found', 'text_domain' ),
    68         'not_found_in_trash'  => __( 'Not found in Trash', 'text_domain' ),
     57        'name'                => _x(),
     58        'singular_name'       => _x(),
     59        'menu_name'           => __(),
     60        'name_admin_bar'      => __(),
     61        'parent_item_colon'   => __(),
     62        'all_items'           => __(),
     63        'add_new_item'        => __(),
     64        'add_new'             => __(),
     65        'new_item'            => __(),
     66        'edit_item'           => __(),
     67        'update_item'         => __(),
     68        'view_item'           => __(),
     69        'search_items'        => __(),
     70        'not_found'           => __(),
     71        'not_found_in_trash'  => __(),
    6972    );
    7073    $args = array(
    71         'label'               => __( 'Quick Faq', 'text_domain' ),
    72         'description'         => __( 'Quick Faq Description', 'text_domain' ),
     74        'label'               => __(),
     75        'description'         => __(),
    7376        'labels'              => $labels,
    74         'supports'            => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'trackbacks', 'revisions', 'custom-fields', 'page-attributes', 'post-formats', ),
    75         'taxonomies'          => array( 'quick_faq_tax' ),
     77        'supports'            => array(),
     78        'taxonomies'          => array(),
    7679        'hierarchical'        => false,
    7780        'public'              => true,
     
    8285        'show_in_nav_menus'   => true,
    8386        'can_export'          => true,
    84         'has_archive'         => true,     
     87        'has_archive'         => true,
    8588        'exclude_from_search' => false,
    8689        'publicly_queryable'  => true,
    8790        'capability_type'     => 'page',
    8891    );
    89     register_post_type( 'quick_faq', $args );
    90 
     92    register_post_type('quick_faq', $args);
    9193}
    92 add_action( 'init', 'post_quick_faq', 0 );
     94add_action();
    9395
    9496
    95 function shortcode_quick_faq( $atts,$content=null) {
     97function shortcode_quick_faq($atts, $content = null)
     98{
    9699    //print_r($atts);
    97     extract( shortcode_atts(
    98         array(
    99         ), $atts )
     100    extract(
     101        shortcode_atts(
     102            array(),
     103            $atts
     104        )
    100105    );
    101    
    102    
     106
     107
    103108    ob_start();
    104109    // WP Query
    105     $WP_Query = new WP_Query( array (
    106                                 'post_type'      => 'quick_faq',
    107                                 'posts_per_page' => -1,
    108                                 'orderby'        => 'post_date',
    109                                 'order'          => 'ASC',
    110                                 'tax_query' => array(
    111                                     array(
    112                                         'taxonomy' =>'quick_faq_tax',
    113                                         'field' => 'id',
    114                                         'terms' => $atts['id']
    115                                         ),
    116                                     )
    117                                 )
    118                         );
     110    $WP_Query = new WP_Query(
     111        array(
     112            'post_type'      => 'quick_faq',
     113            'posts_per_page' => -1,
     114            'orderby'        => 'post_date',
     115            'order'          => 'ASC',
     116            'tax_query' => array(
     117                array(
     118                    'taxonomy' => 'quick_faq_tax',
     119                    'field' => 'id',
     120                    'terms' => $atts['id']
     121                ),
     122            )
     123        )
     124    );
    119125    $i = 1;
    120126    // Displays Post Detail
    121     if( $WP_Query->post_count > 0) :?>
    122    
    123     <ul class="faq">
    124     <?php while ($WP_Query->have_posts()) : $WP_Query->the_post(); ?>
    125        
    126         <li class="q">
    127         <img src='<?php echo plugin_dir_url( __FILE__ )."/arrow.png";?>'>
    128         <?php the_title(); ?>
    129         </li>
    130         <li class="a">
    131             <?php if ( function_exists('has_post_thumbnail') && has_post_thumbnail() ) {
    132                     the_post_thumbnail('thumbnail');
    133                   }
    134             ?>
    135             <?php the_content(); ?>
    136         </li>
    137     <?php $i++; endwhile; ?>
    138     </ul>
     127    if ($WP_Query->post_count > 0) : ?>
     128
     129        <ul class="faq">
     130            <?php while ($WP_Query->have_posts()) : $WP_Query->the_post(); ?>
     131
     132                <li class="q">
     133                    <img src='<?php echo plugin_dir_url(__FILE__) . "/arrow.png"; ?>'>
     134                    <?php the_title(); ?>
     135                </li>
     136                <li class="a">
     137                    <?php if (function_exists('has_post_thumbnail') && has_post_thumbnail()) {
     138                        the_post_thumbnail('thumbnail');
     139                    }
     140                    ?>
     141                    <?php the_content(); ?>
     142                </li>
     143            <?php $i++;
     144            endwhile; ?>
     145        </ul>
    139146    <?php endif; ?>
    140     <?php   return ob_get_clean();
    141     }
    142     add_shortcode("quick_faq", "shortcode_quick_faq");
     147return ob_get_clean();
     148}
     149add_shortcode("quick_faq", "shortcode_quick_faq");
    143150
    144 function quick_faq_scripts() {
    145     //echo '<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>';
    146     echo '<style>
    147     ul.faq{list-style:none;}
    148     .faq li { padding: 20px; }
    149     .faq li.q {
    150       background: #4FC2E;
    151       font-weight: bold;
    152       font-size: 120%;
    153       border-bottom: 1px #ddd solid;
    154       cursor: pointer;
    155      
    156       display: block;
    157     cursor: pointer;
    158     position: relative;
    159     margin: 2px 0 0 0;
    160     padding: .5em .5em .5em .7em;
    161     min-height: 0;
    162     /* support: IE7; */
    163     font-size: 100%;
    164     }
    165 
    166     .faq li.a { 
    167       display: none;
    168      
    169     }
    170    
    171     .rotate {
    172   -moz-transform: rotate(90deg);
    173   -webkit-transform: rotate(90deg);
    174   transform: rotate(90deg);
    175     }
    176     </style>   
    177     ';
    178    
    179     echo "<script>
    180         // Accordian Action
    181     var action = 'click';
    182     var speed = '500';
    183 
    184     jQuery(document).ready(function(){
    185 
    186     // Question handler
    187       jQuery('li.q').on(action, function(){
    188 
    189         // gets next element
    190         // opens .a of selected question
    191         jQuery(this).next().slideToggle(speed)
    192        
    193         // selects all other answers and slides up any open answer
    194         .siblings('li.a').slideUp();
    195      
    196         // Grab img from clicked question
    197         var img = jQuery(this).children('img');
    198 
    199         // remove Rotate class from all images except the active
    200         jQuery('img').not(img).removeClass('rotate');
    201 
    202         // toggle rotate class
    203         img.toggleClass('rotate');
    204 
    205       });
    206 
    207     });
    208     </script>";
     151function quick_faq_scripts()
     152{
     153    wp_enqueue_style('quick-faq-style', plugin_dir_url( __FILE__ ).'/assets/css/accordian_faq.css', array());   
     154    wp_enqueue_script('quick-faq-js', plugin_dir_url( __FILE__ ).'/assets/js/accordian_faq.js', array('jquery'),false);
    209155       
    210156}
    211 add_action( 'wp_head', 'quick_faq_scripts' );
    212 
     157add_action('wp_head', 'quick_faq_scripts');
    213158
    214159
    215160// Taxonomy Shortcode
    216161add_filter("manage_quick_faq_tax_custom_column", 'quick_faq_shortcode_column', 10, 3);
    217 add_filter("manage_edit-quick_faq_tax_columns", 'quick_faq_shortcode_column_head'); 
     162add_filter("manage_edit-quick_faq_tax_columns", 'quick_faq_shortcode_column_head');
    218163
    219 function quick_faq_shortcode_column_head($theme_columns) {
    220     $new_columns = array(
    221             'cb' => '<input type="checkbox" />',
    222             'name' => __('Name'),
    223             'quick_faq_shortcode' => __( 'Shortcode', 'quick_faq' ),
    224             'slug' => __('Slug'),
    225             'posts' => __('Posts')
    226         );
    227     return $new_columns;
     164function quick_faq_shortcode_column_head($theme_columns)
     165{
     166    $new_columns = array(
     167        'cb' => '<input type="checkbox" />',
     168        'name' => __('Name'),
     169        'quick_faq_shortcode' => __('Shortcode', 'quick_faq'),
     170        'slug' => __('Slug'),
     171        'posts' => __('Posts')
     172    );
     173    return $new_columns;
    228174}
    229175
    230 function quick_faq_shortcode_column($out, $column_name, $theme_id) {
    231     $theme = get_term($theme_id, 'quick_faq_tax');
    232     switch ($column_name) {
    233        
    234         case 'title':
    235             echo get_the_title();
    236         break;
     176function quick_faq_shortcode_column($out, $column_name, $theme_id)
     177{
     178    $theme = get_term($theme_id, 'quick_faq_tax');
     179    switch ($column_name) {
    237180
    238         case 'quick_faq_shortcode':             
    239              echo '[quick_faq ID="'. $theme_id.'"]';
    240         break;
    241  
    242         default:
    243             break;
    244     }
    245     return $out;   
     181        case 'title':
     182            echo get_the_title();
     183            break;
     184
     185        case 'quick_faq_shortcode':
     186            echo '[quick_faq ID="' . $theme_id . '"]';
     187            break;
     188
     189        default:
     190            break;
     191    }
     192    return $out;
    246193}
Note: See TracChangeset for help on using the changeset viewer.