create_table(); } /** * i18n. * * @version 1.0.0 * @since 1.0.0 */ public function plugins_loaded () { load_plugin_textdomain( $this->text_domain, false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); } /** * admin_init. * * @version 1.0.0 * @since 1.0.0 */ public function admin_init () { wp_register_style( 'add-banner-extension-admin-style', plugins_url( 'css/style.css', __FILE__ ), array(), $this->version ); } /** * Admin menu. * * @version 1.0.0 * @since 1.0.0 */ public function admin_menu () { add_menu_page( __( 'Add Banner Extension' , $this->text_domain ), __( 'Add Banner' , $this->text_domain ), 'manage_options', plugin_basename( __FILE__ ), array( $this, 'list_page_render' ), 'dashicons-format-gallery' ); $list_page = add_submenu_page( __FILE__, __( 'All Banner List' , $this->text_domain ), __( 'All Banner List' , $this->text_domain ), 'manage_options', plugin_basename( __FILE__ ), array( $this, 'list_page_render' ) ); $post_page = add_submenu_page( __FILE__, __( 'Add New' , $this->text_domain ), __( 'Add New' , $this->text_domain ), 'manage_options', plugin_dir_path( __FILE__ ) . 'includes/add-banner-admin-post.php', array( $this, 'post_page_render' ) ); add_action( 'admin_print_styles-' . $list_page, array( $this, 'add_style' ) ); add_action( 'admin_print_styles-' . $post_page, array( $this, 'add_style' ) ); add_action( 'admin_print_scripts-' . $post_page, array( $this, 'add_scripts' ) ); } /** * Admin List Page Template Require. * * @version 1.0.0 * @since 1.0.0 */ public function list_page_render () { require_once( plugin_dir_path( __FILE__ ) . 'includes/add-banner-admin-list.php' ); new add_Banner_Extension_Admin_List( $this->text_domain ); } /** * Admin Post Page Template Require. * * @version 1.0.0 * @since 1.0.0 */ public function post_page_render () { require_once( plugin_dir_path( __FILE__ ) . 'includes/add-banner-admin-post.php' ); new add_Banner_Extension_Admin_Post( $this->text_domain ); } /** * Admin CSS Add. * * @version 1.0.0 * @since 1.0.0 */ public function add_style () { wp_enqueue_style( 'add-banner-extension-admin-style' ); } /** * Admin Scripts Add. * * @version 1.0.0 * @since 1.0.0 */ public function add_scripts () { wp_enqueue_media(); } /** * Display Banner * * @version 1.0.0 * @since 1.0.0 * @param string $content * @return string $content */ public function the_content ( $content ) { if ( !is_single() ) { return $content; } $html = ''; $categories = get_the_category(); if ( count( $categories ) > 0 ) { require_once( plugin_dir_path( __FILE__ ) . 'includes/add-banner-admin-db.php' ); $db = new add_Banner_Extension_Admin_Db(); $args = $db->get_categories( $categories[0]->cat_ID ); foreach ( $args as $value ) { $html .= '
'; } } return $content . $html; } }