Plugin Directory

Changeset 2547212


Ignore:
Timestamp:
06/14/2021 04:19:47 AM (5 years ago)
Author:
serviceslbk
Message:

init 1.1.0

Location:
lbk-faqs-schema/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • lbk-faqs-schema/trunk/includes/class.admin.php

    r2521785 r2547212  
    3131            add_action( 'save_post', array( $this, 'lbk_custom_faq_save' ) );
    3232            add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_script' ) );
    33             // add_action( 'init', array( $this, 'lbk_register_meta_fields' ) );
    3433        }
    3534
     
    6867            ?>
    6968       
    70             <a href="#" class="button" id="add_new_faq_button">Add New</a>
    71             <table id="lbk_list_faqs" style="width:100%">
    72                 <thead>
    73                     <tr>
    74                         <th>Question</th>
    75                         <th>Answer</th>
    76                         <th>Remove</th>
    77                     </tr>
    78                 </thead>
    79                 <tbody>
    80                 <?php $c = 0; ?>
    81                 <?php if ($custom_faqs > 0) : ?>
    82                     <?php foreach($custom_faqs as $faq) : ?>
    83                         <tr id="faq-<?php echo $c ?>">
    84                             <input type="hidden" class="faq-id" value="<?php echo $c; ?>">
    85                             <td class="faqData">
    86                                 <input name="lbk_faq_custom[<?php echo $c; ?>][question]" value="<?php echo esc_textarea($faq['question']); ?>" style="width:100%">
    87                             </td>
    88                             <td class="faqData">
    89                                 <textarea name="lbk_faq_custom[<?php echo $c; ?>][answer]" style="width:100%" rows="3"><?php echo esc_textarea($faq['answer']); ?></textarea>
    90                             </td>
    91                             <td style="text-align:center;">
    92                                 <a href="#" class="button" id="lbk_delete_faq" data-id="<?php echo $c; ?>">Delete</a>
    93                             </td>
    94                         </tr>
    95                         <?php $c++; ?>
    96                     <?php endforeach; ?>
    97                 <?php endif; ?>
    98                 </tbody>
    99             </table>
     69            <div class="lbk_list_faqs" id="lbk_list_faqs">
     70                <a href="#" class="button" id="add_new_faqs_button" style="margin: 5px auto;">Add New</a>
     71                <div id="lbk_list_faqs_inner" style="width:100%">
     72                    <?php if ( $custom_faqs > 0 ) : $c = 1; $args['textarea_name'] = "lbk_faqs_custom[{$c}][answer]"; ?>
     73                        <?php foreach( $custom_faqs as $faqs ) : ?>
     74                            <div class="collapsible state-close" id="faqs-<?php echo $c ?>">
     75                                <div class="collapsible_heading">
     76                                    <h4>Question <?php echo $c; ?></h4>
     77                                    <a href="#" class="button" id="lbk_delete_faqs" data-id="<?php echo $c; ?>">Remove</a>
     78                                    <button class="collapsible_button">
     79                                        <span class="collapsible-icon-toggle"></span>
     80                                    </button>
     81                                </div>
     82                                <div class="faqs-content collapsible_content">
     83                                    <input type="hidden" class="faqs-id" value="<?php echo $c; ?>">
     84                                    <div class="faqsData">
     85                                        <h4>Question</h4>
     86                                        <input name="lbk_faqs_custom[<?php echo $c; ?>][question]" value="<?php echo esc_textarea($faqs['question']); ?>" style="width:100%">
     87                                    </div>
     88                                    <div class="faqsData">
     89                                        <h4>Answer</h4>
     90                                        <?php wp_editor( esc_textarea($faqs['answer']), "answer-{$c}", $args ); ?>
     91                                    </div>
     92                                </div>
     93                            </div>
     94                            <?php $c++; ?>
     95                        <?php endforeach; ?>
     96                    <?php endif; ?>
     97                </div>
     98            </div>
    10099            <?php
    101100        }
     
    136135         */
    137136        public function enqueue_script() {
    138             wp_enqueue_script('lbk-custom-faq', LBK_FAQ_URL.'js/admin.js', array(), '1.0.0', 'all' );
     137            wp_enqueue_editor();
     138            $localize = array(
     139                'ajaxurl' => admin_url( 'admin-ajax.php' )
     140            );
     141
     142            wp_enqueue_script('lbk-custom-faq', LBK_FAQ_URL.'js/admin.js', array( 'jquery' ), '1.0.0', 'all' );
     143            wp_localize_script( 'lbk-custom-faq', 'lbk_custom_faq_script', $localize);
     144
     145            wp_enqueue_style( 'lbk-faqs', LBK_FAQ_URL . 'css/admin.css', array(), '1.0.0', 'all' );
    139146        }
    140 
    141         /**
    142          * Sanitize faqs field
    143          *
    144          * @access private
    145          * @since 1.0
    146          * @static
    147          */
    148         // public function lbk_register_meta_fields() {
    149         //     $args = array(
    150         //         'sanitize_callback' => 'sanitize_faqs_field'
    151         //     );
    152            
    153         //     register_meta( 'post', '_lbk_custom_faqs', $args );
    154         // }
    155147    }
    156148    new lbkFAQs_Admin();
Note: See TracChangeset for help on using the changeset viewer.