| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | if ( ! defined( 'ABSPATH' ) ) { |
| 14: | exit; |
| 15: | } |
| 16: | |
| 17: | global $epl_contact_page_hook; |
| 18: | |
| 19: | add_action( 'admin_menu', 'epl_admin_menu' ); |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | |
| 27: | function epl_admin_menu() { |
| 28: | global $epl_contact_page_hook; |
| 29: | |
| 30: | $menu_title = __( 'Easy Property Listings', 'easy-property-listings' ); |
| 31: | $page_title = __( 'Easy Property Listings', 'easy-property-listings' ); |
| 32: | $capability = 'edit_posts'; |
| 33: | $menu_slug = 'epl-general'; |
| 34: | $main_menu_slug = $menu_slug; |
| 35: | $function = 'epl_menu_general'; |
| 36: | $icon = 'dashicons-portfolio'; |
| 37: | $position = '25.9'; |
| 38: | add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon, $position ); |
| 39: | |
| 40: | $page_title = __( 'Help', 'easy-property-listings' ); |
| 41: | $menu_title = __( 'Help', 'easy-property-listings' ); |
| 42: | add_submenu_page( $menu_slug, $page_title, $menu_title, $capability, $menu_slug, $function ); |
| 43: | |
| 44: | |
| 45: | $page_title = __( 'Settings', 'easy-property-listings' ); |
| 46: | $menu_title = __( 'Settings', 'easy-property-listings' ); |
| 47: | $capability = 'manage_options'; |
| 48: | $function = 'epl_menu_settings'; |
| 49: | $menu_slug = 'epl-settings'; |
| 50: | add_submenu_page( $main_menu_slug, $page_title, $menu_title, $capability, $menu_slug, $function ); |
| 51: | |
| 52: | |
| 53: | $page_title = __( 'Contacts', 'easy-property-listings' ); |
| 54: | $menu_title = __( 'Contacts', 'easy-property-listings' ); |
| 55: | $menu_slug = 'epl-contacts'; |
| 56: | $function = 'epl_contacts_page'; |
| 57: | $this_user = wp_get_current_user(); |
| 58: | if ( epl_contact_access() ) { |
| 59: | $capability = ! empty( $this_user->roles[0] ) ? $this_user->roles[0] : 'manage_options'; |
| 60: | $epl_contact_page_hook = add_submenu_page( $main_menu_slug, $page_title, $menu_title, $capability, $menu_slug, $function ); |
| 61: | } |
| 62: | |
| 63: | |
| 64: | $page_title = __( 'Reports', 'easy-property-listings' ); |
| 65: | $menu_title = __( 'Reports', 'easy-property-listings' ); |
| 66: | $capability = 'edit_published_posts'; |
| 67: | $menu_slug = 'epl-reports'; |
| 68: | $function = 'epl_reports_page'; |
| 69: | if ( epl_reports_access() ) { |
| 70: | $capability = $this_user->roles[0]; |
| 71: | $epl_reports_page_hook = add_submenu_page( $main_menu_slug, $page_title, $menu_title, $capability, $menu_slug, $function ); |
| 72: | } |
| 73: | |
| 74: | |
| 75: | $capability = 'manage_options'; |
| 76: | |
| 77: | |
| 78: | if ( has_filter( 'epl_extensions_options_filter_new' ) ) { |
| 79: | $page_title = __( 'Extensions', 'easy-property-listings' ); |
| 80: | $menu_title = __( 'Extensions', 'easy-property-listings' ); |
| 81: | $menu_slug = 'epl-extensions'; |
| 82: | $function = 'epl_menu_extensions'; |
| 83: | add_submenu_page( $main_menu_slug, $page_title, $menu_title, $capability, $menu_slug, $function ); |
| 84: | } |
| 85: | |
| 86: | if ( has_filter( 'epl_extensions_options_filter' ) ) { |
| 87: | |
| 88: | $page_title_old = __( 'Extensions Updates', 'easy-property-listings' ); |
| 89: | $menu_title_old = '<span style="color:#ff0000">' . __( 'Update Extensions', 'easy-property-listings' ) . '</span>'; |
| 90: | $menu_slug_old = 'epl-extensions-compat'; |
| 91: | $function_old = 'epl_menu_extensions_compat'; |
| 92: | add_submenu_page( $main_menu_slug, $page_title_old, $menu_title_old, $capability, $menu_slug_old, $function_old ); |
| 93: | } |
| 94: | |
| 95: | |
| 96: | if ( has_filter( 'epl_license_options_filter' ) ) { |
| 97: | $page_title = __( 'Licenses', 'easy-property-listings' ); |
| 98: | $menu_title = __( 'Licenses', 'easy-property-listings' ); |
| 99: | $menu_slug = 'epl-licenses'; |
| 100: | $function = 'epl_menu_licenses'; |
| 101: | add_submenu_page( $main_menu_slug, $page_title, $menu_title, $capability, $menu_slug, $function ); |
| 102: | } |
| 103: | |
| 104: | |
| 105: | $page_title = __( 'Add Ons', 'easy-property-listings' ); |
| 106: | $menu_title = __( 'Add Ons', 'easy-property-listings' ); |
| 107: | $capability = 'edit_published_posts'; |
| 108: | $menu_slug = 'epl-addons'; |
| 109: | $function = 'epl_menu_addons'; |
| 110: | add_submenu_page( $main_menu_slug, $page_title, $menu_title, $capability, $menu_slug, $function ); |
| 111: | |
| 112: | |
| 113: | $page_title = __( 'Tools', 'easy-property-listings' ); |
| 114: | $menu_title = __( 'Tools', 'easy-property-listings' ); |
| 115: | $capability = 'manage_options'; |
| 116: | $menu_slug = 'epl-tools'; |
| 117: | $function = 'epl_menu_tools'; |
| 118: | add_submenu_page( $main_menu_slug, $page_title, $menu_title, $capability, $menu_slug, $function ); |
| 119: | } |
| 120: | |
| 121: | |
| 122: | |
| 123: | |
| 124: | |
| 125: | |
| 126: | function epl_menu_general() { |
| 127: | if ( ! current_user_can( 'edit_posts' ) ) { |
| 128: | wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'easy-property-listings' ) ); |
| 129: | } |
| 130: | require_once 'menu-help.php'; |
| 131: | } |
| 132: | |
| 133: | |
| 134: | |
| 135: | |
| 136: | |
| 137: | |
| 138: | function epl_menu_settings() { |
| 139: | if ( ! current_user_can( 'manage_options' ) ) { |
| 140: | wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'easy-property-listings' ) ); |
| 141: | } |
| 142: | require_once 'menu-general.php'; |
| 143: | } |
| 144: | |
| 145: | |
| 146: | |
| 147: | |
| 148: | |
| 149: | |
| 150: | function epl_menu_extensions() { |
| 151: | if ( ! current_user_can( 'manage_options' ) ) { |
| 152: | wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'easy-property-listings' ) ); |
| 153: | } |
| 154: | require_once 'menu-extensions.php'; |
| 155: | } |
| 156: | |
| 157: | |
| 158: | |
| 159: | |
| 160: | |
| 161: | |
| 162: | function epl_menu_licenses() { |
| 163: | if ( ! current_user_can( 'manage_options' ) ) { |
| 164: | wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'easy-property-listings' ) ); |
| 165: | } |
| 166: | require_once 'menu-licenses.php'; |
| 167: | } |
| 168: | |
| 169: | |
| 170: | |
| 171: | |
| 172: | |
| 173: | |
| 174: | function epl_menu_addons() { |
| 175: | if ( ! current_user_can( 'edit_published_posts' ) ) { |
| 176: | wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'easy-property-listings' ) ); |
| 177: | } |
| 178: | require_once 'menu-addons.php'; |
| 179: | } |
| 180: | |
| 181: | |
| 182: | |
| 183: | |
| 184: | |
| 185: | |
| 186: | function epl_menu_help() { |
| 187: | if ( ! current_user_can( 'edit_posts' ) ) { |
| 188: | wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'easy-property-listings' ) ); |
| 189: | } |
| 190: | require_once 'menu-help.php'; |
| 191: | } |
| 192: | |
| 193: | |
| 194: | |
| 195: | |
| 196: | |
| 197: | |
| 198: | function epl_menu_tools() { |
| 199: | if ( ! current_user_can( 'manage_options' ) ) { |
| 200: | wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'easy-property-listings' ) ); |
| 201: | } |
| 202: | require_once 'menu-tools.php'; |
| 203: | } |
| 204: | |