plugin_name = $plugin_name; $this->version = $version; } /** * Register the stylesheets for the public-facing side of the site. * * @since 1.0.0 */ public function enqueue_styles() { wp_register_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/dickensos-accordion-faq-public.css', array(), $this->version, 'all' ); global $skelet_path; wp_register_style( 'sk-icons', $skelet_path["uri"] .'/assets/css/sk-icons.css', array(), '1.0.0', 'all' ); } /** * Register the stylesheets for the public-facing side of the site. * * @since 1.0.0 */ public function enqueue_scripts() { global $pafa; wp_register_script( $this->plugin_name , plugin_dir_url(__FILE__) . 'js/dickensos-accordion-faq-public.js', array( 'jquery' ), $this->version, false ); wp_localize_script( $this->plugin_name, "icons", array ( 'faq_close' => $pafa->get('icon_closed') != '' ? $pafa->get('icon_closed') : 'sk-plus-add', 'faq_open' => $pafa->get('icon_opened') != '' ? $pafa->get('icon_opened') : 'sk-minus', ) ); } /** * Registers all shortcodes at once */ public function register_shortcodes() { /** * Register shortcode eg: * add_shortcode( 'voting_butons', array( $this, 'shortcode_voting_butons' ) ); */ add_shortcode( 'faq', array( $this, 'shortcode_faq' ) ); add_shortcode( 'pafa_faq', array( $this, 'shortcode_faq' ) ); } public function shortcode_faq( $atts = array() ) { return $this->get_display_faq($atts); } /** * * return the Final output of the FAQ html generated based on the template file * and Data based on the parameter * * @param array $args * @return string */ public function get_display_faq( $args = array() ) { global $pafa_faq_data,$pafa; $default = array ( 'category' => -1, 'template' => 'accordion', 'bg_color' => '#ef3737', 'icon_bg_color' => '#ef3737', 'icon_bg_radius' => '0', 'block_radius' => '0', 'icon_color' => '#ffffff' ); $args = shortcode_atts($default,$args); if ( $pafa->get('reorder') == 1 ) { $qry_args = array( 'post_type' => 'faq', 'numberposts' => -1, 'orderby' => 'menu_order', 'order' => 'ASC', ); } else { $qry_args = array( 'post_type' => 'faq', 'numberposts' => -1, ); } if( isset( $args['category'] ) && $args['category'] != -1 ) { $qry_args['tax_query'] = array( array( 'taxonomy' => 'faq_category', 'field' => 'id', 'terms' => $args['category'], ), ); $dickensos_terms = get_terms('faq_category', array( 'child_of' => $args['category'] ) ); if ( $pafa->get('reorder') == 1 ) { $dickensos_terms = get_terms('faq_category', array( 'child_of' => $args['category'], 'orderby' => 'term_group', 'order' => 'ASC' ) ); } else { $dickensos_terms = get_terms('faq_category', array( 'child_of' => $args['category'] ) ); } } else { if ( $pafa->get('reorder') == 1 ) { $dickensos_terms = get_terms('faq_category', array( 'orderby' => 'term_group', 'order' => 'ASC' ) ); } else { $dickensos_terms = get_terms('faq_category'); } } if ( count( $dickensos_terms ) > 0 ) { foreach ( $dickensos_terms as $term ) { $dickensos_terms_questions[ $term->term_id ] = get_posts( array_merge( $qry_args, array('tax_query' => array( array( 'taxonomy' => 'faq_category', 'field' => 'id', 'terms' => $term->term_id, ) ) ) )); } $pafa_faq_data = array( 'dispaly_terms' => TRUE, 'terms' => $dickensos_terms, 'questions' => $dickensos_terms_questions, 'template' => $args['template'], ); } else { $dickensos_question = get_posts($qry_args); $pafa_faq_data = array( 'dispaly_terms' => FALSE, 'questions' => $dickensos_question, 'template' => $args['template'], ); } /** * Select the Proper Template file to be Render the FAQ Structure * */ $default_filename = plugin_dir_path( __FILE__ ) . "partials/dickensos-accordion-faq-public-list.php"; $theme_default_filename = get_stylesheet_directory() . "/dickensos-accordion-faq-public-list.php"; $default_template_filename = plugin_dir_path( __FILE__ ) . "partials/dickensos-accordion-faq-public-{$args['template']}.php"; $theme_template_filename = get_stylesheet_directory() . "/dickensos-accordion-faq-public-{$args['template']}.php"; if( @file_exists( $theme_template_filename ) ) { $filename = $theme_template_filename; } elseif( @file_exists( $default_template_filename ) ) { $filename = $default_template_filename; } elseif( @file_exists( $theme_default_filename ) ) { $filename = $theme_default_filename; }else{ $filename = $default_filename; } ob_start(); include $filename; //enqueue frontend js wp_enqueue_script( $this->plugin_name ); wp_enqueue_style( 'sk-icons' ); wp_enqueue_style( $this->plugin_name ); if( is_admin() ) { wp_enqueue_style( $this->plugin_name ); } wp_reset_query(); return ob_get_clean(); } function dynamic_css() { global $pafa; $css = '\n"; echo $css; } }