addAdminMenu(); } return self::$instance; } public function adminMenu() { add_menu_page( 'AdFoxly - Dashboard', 'AdFoxly', 'manage_options', 'adfoxly', array( $this, 'wpadsDashboardPage' ), plugins_url( 'admin/img/icon.png', dirname( __FILE__ ) ), '80.321' ); add_submenu_page( 'adfoxly', __( 'Create ad', 'adfoxly' ), __( 'Create ad', 'adfoxly' ), 'manage_options', 'adfoxly-new', array( $this, 'wpadsAdsNew' ) ); add_submenu_page( 'adfoxly', __( 'Ads', 'adfoxly' ), __( 'Ads', 'adfoxly' ), 'manage_options', // 'edit.php?post_type=adfoxly_banners' 'adfoxly-banners', array( $this, 'wpadsBannersPage' ) ); add_submenu_page( 'adfoxly', __( 'Places', 'adfoxly' ), __( 'Places', 'adfoxly' ), 'manage_options', 'adfoxly-places', array( $this, 'wpadsPlacesPage' ) ); add_submenu_page( 'adfoxly', __( 'Groups', 'adfoxly' ), __( 'Groups', 'adfoxly' ), 'manage_options', 'adfoxly-groups', array( $this, 'wpadsGroupsPage' ) ); add_submenu_page( 'adfoxly', __( 'Campaigns', 'adfoxly' ), __( 'Campaigns', 'adfoxly' ), 'manage_options', 'adfoxly-campaigns', array( $this, 'wpadsCampaignsPage' ) ); } public function addAdminMenu() { add_action( 'admin_menu', array( $this, 'adminMenu' ) ); } public function wpadsPlacesPage() { require_once dirname( dirname( __FILE__ ) ) . '/admin/partials/adfoxly-admin-places.php'; } public function wpadsBannersPage() { require_once dirname( dirname( __FILE__ ) ) . '/includes/controller/adfoxly-new.php'; } public function wpadsAdsNew() { require_once dirname( dirname( __FILE__ ) ) . '/includes/controller/adfoxly-new.php'; } public function wpadsDashboardPage() { require_once dirname( dirname( __FILE__ ) ) . '/admin/partials/adfoxly-admin-display.php'; } public function wpadsGroupsPage() { require_once dirname( dirname( __FILE__ ) ) . '/admin/partials/adfoxly-admin-groups.php'; } public function wpadsCampaignsPage() { require_once dirname( dirname( __FILE__ ) ) . '/admin/partials/adfoxly-admin-campaigns.php'; } } // Call the class and add the menus automatically. $AdFoxlyMenu = AdFoxlyMenu::instance(); if ( ! function_exists( 'adfoxly_banners' ) ) { // Register Custom Post Type function adfoxly_banners() { $labels = array( 'name' => _x( 'Banners', 'Post Type General Name', 'adfoxly' ), 'singular_name' => _x( 'Banner', 'Post Type Singular Name', 'adfoxly' ), 'menu_name' => __( 'Ads Manager', 'adfoxly' ), 'name_admin_bar' => __( 'Ads Manager', 'adfoxly' ), 'archives' => __( 'Item Archives', 'adfoxly' ), 'attributes' => __( 'Item Attributes', 'adfoxly' ), 'parent_item_colon' => __( 'Parent Item:', 'adfoxly' ), 'all_items' => __( 'All Banners', 'adfoxly' ), 'add_new_item' => __( 'Add New Item', 'adfoxly' ), 'add_new' => __( 'Add Banner', 'adfoxly' ), 'new_item' => __( 'New Banner', 'adfoxly' ), 'edit_item' => __( 'Edit Banner', 'adfoxly' ), 'update_item' => __( 'Update Banner', 'adfoxly' ), 'view_item' => __( 'View Banner', 'adfoxly' ), 'view_items' => __( 'View Banner', 'adfoxly' ), 'search_items' => __( 'Search Banners', 'adfoxly' ), 'not_found' => __( 'Not found', 'adfoxly' ), 'not_found_in_trash' => __( 'Not found in Trash', 'adfoxly' ), 'featured_image' => __( 'Featured Image', 'adfoxly' ), 'set_featured_image' => __( 'Set featured image', 'adfoxly' ), 'remove_featured_image' => __( 'Remove featured image', 'adfoxly' ), 'use_featured_image' => __( 'Use as featured image', 'adfoxly' ), 'insert_into_item' => __( 'Insert into item', 'adfoxly' ), 'uploaded_to_this_item' => __( 'Uploaded to this item', 'adfoxly' ), 'items_list' => __( 'Items list', 'adfoxly' ), 'items_list_navigation' => __( 'Items list navigation', 'adfoxly' ), 'filter_items_list' => __( 'Filter items list', 'adfoxly' ), ); $args = array( 'label' => __( 'Banner', 'adfoxly' ), 'description' => __( 'Post Type Description', 'adfoxly' ), 'labels' => $labels, 'supports' => array( 'title' ), 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_in_menu' => false, 'menu_position' => 75, 'show_in_admin_bar' => true, 'show_in_nav_menus' => true, 'can_export' => true, 'has_archive' => false, 'exclude_from_search' => true, 'publicly_queryable' => false, 'capability_type' => 'page', 'show_in_rest' => false, ); register_post_type( 'adfoxly_banners', $args ); } add_action( 'init', 'adfoxly_banners', 0 ); } if ( ! function_exists( 'adfoxly_ad_group' ) ) { // Register Custom Post Type function adfoxly_ad_group() { $adfoxly_ad_group_labels = array( 'name' => _x( 'Groups', 'Post Type General Name', 'adfoxly' ), 'singular_name' => _x( 'Group', 'Post Type Singular Name', 'adfoxly' ), 'menu_name' => __( 'Ads Manager', 'adfoxly' ), 'name_admin_bar' => __( 'Ads Manager', 'adfoxly' ), 'archives' => __( 'Item Archives', 'adfoxly' ), 'attributes' => __( 'Item Attributes', 'adfoxly' ), 'parent_item_colon' => __( 'Parent Item:', 'adfoxly' ), 'all_items' => __( 'All Groups', 'adfoxly' ), 'add_new_item' => __( 'Add New Item', 'adfoxly' ), 'add_new' => __( 'Add Group', 'adfoxly' ), 'new_item' => __( 'New Group', 'adfoxly' ), 'edit_item' => __( 'Edit Group', 'adfoxly' ), 'update_item' => __( 'Update Group', 'adfoxly' ), 'view_item' => __( 'View Group', 'adfoxly' ), 'view_items' => __( 'View Groups', 'adfoxly' ), 'search_items' => __( 'Search Groups', 'adfoxly' ), 'not_found' => __( 'Not found', 'adfoxly' ), 'not_found_in_trash' => __( 'Not found in Trash', 'adfoxly' ), 'featured_image' => __( 'Featured Image', 'adfoxly' ), 'set_featured_image' => __( 'Set featured image', 'adfoxly' ), 'remove_featured_image' => __( 'Remove featured image', 'adfoxly' ), 'use_featured_image' => __( 'Use as featured image', 'adfoxly' ), 'insert_into_item' => __( 'Insert into item', 'adfoxly' ), 'uploaded_to_this_item' => __( 'Uploaded to this item', 'adfoxly' ), 'items_list' => __( 'Items list', 'adfoxly' ), 'items_list_navigation' => __( 'Items list navigation', 'adfoxly' ), 'filter_items_list' => __( 'Filter items list', 'adfoxly' ), ); $adfoxly_ad_group_args = array( 'label' => __( 'Groups', 'adfoxly' ), 'description' => __( 'Post Type Description', 'adfoxly' ), 'labels' => $adfoxly_ad_group_labels, 'supports' => array( 'title' ), 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_in_menu' => false, 'menu_position' => 75, 'show_in_admin_bar' => true, 'show_in_nav_menus' => true, 'can_export' => true, 'has_archive' => false, 'exclude_from_search' => true, 'publicly_queryable' => false, 'capability_type' => 'page', 'show_in_rest' => false, ); register_post_type( 'adfoxly_ad_group', $adfoxly_ad_group_args ); } add_action( 'init', 'adfoxly_ad_group', 0 ); } add_action( 'manage_adfoxly_banners_posts_columns', 'rating_columns', 10, 2 ); function rating_columns( $columns ) { global $post; return array_merge( $columns, array( 'thumbnail' => __( 'Thumbnail' ), 'place' => __( 'Place' ) ) ); } add_action( 'manage_posts_custom_column', 'add_rating_columns' ); function add_rating_columns( $column ) { global $post; switch ( $column ) { case 'thumbnail': $metaData = get_post_meta( $post->ID, 'adfoxly-image', true ); echo ""; break; case 'place': $metaData = get_post_meta( $post->ID, 'adfoxly-adzone-place', true ); $places = array( 3 => array( 'name' => 'Before post', 'image' => 'before_content.svg' ), 4 => array( 'name' => 'After post', 'image' => 'after_content.svg' ), 5 => array( 'name' => 'Inside the post content', 'image' => 'inside_content.svg' ), // 8 => array( 'name' => 'Before comments', 'image' => 'before_comments.svg' ), 9 => array( 'name' => 'After comments', 'image' => 'after_comments.svg' ), // 10 => array( 'name' => 'Between comments', 'image' => 'inside_comments.svg' ), 1 => array( 'name' => 'Popup on Start', 'image' => 'popup.svg' ), 6 => array( 'name' => 'Background', 'image' => 'background.svg' ), 7 => array( 'name' => 'WordPress Widget', 'image' => 'widget.svg' ), 2 => array( 'name' => 'Adzone in Redirection', 'image' => 'redirection.svg' ), ); $adzone_place_listing = ''; foreach ( $places as $place_id => $place ): if ( isset( $metaData ) && ! empty( $metaData ) && in_array( $place_id, $metaData ) ): $adzone_place_listing .= $place[ 'name' ] . ", "; endif; endforeach; echo "" . $adzone_place_listing . ""; break; } } function add_adzones_columns( $column ) { global $post; switch ( $column ) { case 'place': $metaData = get_post_meta( $post->ID, 'adfoxly-adzone-place', true ); if ( ! empty( $metaData ) ): $countPlaces = count( $metaData ); $i = 1; foreach ( $metaData as $placeID ): switch ( $placeID ): case 1: echo "Popup on Start"; if ( $i < $countPlaces ): echo ", "; endif; $i ++; break; case 2: echo "Adzone in Redirection"; if ( $i < $countPlaces ): echo ", "; endif; $i ++; break; case 3: echo "Before post"; if ( $i < $countPlaces ): echo ", "; endif; $i ++; break; case 4: echo "After post"; if ( $i < $countPlaces ): echo ", "; endif; $i ++; break; case 5: echo "Inside the post content"; if ( $i < $countPlaces ): echo ", "; endif; $i ++; break; case 6: echo "Background"; if ( $countPlaces < $i ): echo ", "; endif; $i ++; break; case 7: echo "WordPress Widget"; if ( $countPlaces < $i ): echo ", "; endif; $i ++; break; endswitch; endforeach; endif; // echo "" . $adzoneName->post_title . " (id: $metaData)"; break; } } //add_submenu_page( 'edit.php?post_type=adfoxly_banners&page=adfoxly-settings', __( 'Statistics' ), __( 'Statistics' ), 'manage_options', 'statistics', 'adfoxly_banners_statistics' ); add_action( 'admin_menu', 'my_menu' ); function my_menu() { add_submenu_page( 'adfoxly', __( 'Settings' ), __( 'Settings' ), 'manage_options', 'adfoxly-settings', 'adfoxly_banners_settings' ); } function adfoxly_banners_settings() { require_once dirname( dirname( __FILE__ ) ) . "/admin/partials/adfoxly-admin-settings.php"; } function adfoxly_banners_statistics() { echo "test"; } // // //add_submenu_page( // 'edit.php?post_type=book', // __( 'Books Shortcode Reference', 'textdomain' ), // __( 'Shortcode Reference', 'textdomain' ), // 'manage_options', // 'books-shortcode-ref', // 'books_ref_page_callback' //);