__( 'Configuration', DFRAPI_DOMAIN ), 'dfrapi-networks' => __( 'Networks', DFRAPI_DOMAIN ), 'dfrapi-merchants' => __( 'Merchants', DFRAPI_DOMAIN ), 'dfrapi-tools' => __( 'Tools', DFRAPI_DOMAIN ), 'dfrapi-export' => __( 'Export', DFRAPI_DOMAIN ), 'dfrapi-import' => __( 'Import', DFRAPI_DOMAIN ), 'dfrapi-account' => __( 'Account', DFRAPI_DOMAIN ), ); if ( isset( $pages[$key] ) ) { return $pages[$key]; } } /** * This stores messages to be displayed using the * 'admin_notices' action. */ function dfrapi_admin_messages( $key=false ) { $messages = array( // User is missing 1 or more of their API Keys. 'missing_api_keys' => array( 'class' => 'update-nag', 'message' => __( 'Your Datafeedr API Keys are missing.', DFRAPI_DOMAIN ), 'url' => 'admin.php?page=dfrapi', 'button_text' => __( 'Add Your API Keys', DFRAPI_DOMAIN ) ), // User is missing a network 'missing_network_ids' => array( 'class' => 'update-nag', 'message' => __( 'You haven\'t selected any affiliate networks yet.', DFRAPI_DOMAIN ), 'url' => 'admin.php?page=dfrapi_networks', 'button_text' => __( 'Select Networks', DFRAPI_DOMAIN ) ), // User is missing a merchant 'missing_merchant_ids' => array( 'class' => 'update-nag', 'message' => __( 'You haven\'t selected any merchants yet.', DFRAPI_DOMAIN ), 'url' => 'admin.php?page=dfrapi_merchants', 'button_text' => __( 'Select Merchants', DFRAPI_DOMAIN ) ), // Display message that user has used 90%+ of API requests. 'usage_over_90_percent' => array( 'class' => 'update-nag', 'message' => __( 'You have used ', DFRAPI_DOMAIN ) . dfrapi_get_api_usage_percentage() . __( '% of your total Datafeedr API requests this month. ', DFRAPI_DOMAIN ), 'url' => 'admin.php?page=dfrapi_account', 'button_text' => __( 'View Account', DFRAPI_DOMAIN ) ), // Missing affiliate IDs message. 'missing_affiliate_ids' => array( 'class' => 'update-nag', 'message' => __( 'You are missing affiliate IDs. ', DFRAPI_DOMAIN ), 'url' => 'admin.php?page=dfrapi_networks', 'button_text' => __( 'Enter your Affiliate IDs', DFRAPI_DOMAIN ) ), ); if ( isset( $messages[$key] ) ) { dfrapi_admin_notices( $key, $messages ); } } /** * This gets any notices set by the plugin. */ function dfrapi_admin_notices( $key, $messages ) { $notices = get_option( 'dfrapi_admin_notices', array() ); $notices[$key] = $messages[$key]; update_option( 'dfrapi_admin_notices', $notices ); } /** * Button text for admin notices. */ function dfrapi_fix_button( $url, $button_text=false ) { if ( !$button_text ) { $button_text = __( 'Fix This Now', DFRAPI_DOMAIN ); } if ( substr( $url, 0, 4 ) === "http" ) { return ' ' .$button_text . ''; } else { return ' ' .$button_text . ''; } } /** * Return plan IDs & names. */ function dfrapi_get_membership_plans() { return array( 10200 => 'Free', 101000 => 'Starter', 1025000 => 'Basic', 1125000 => 'Beta Tester', 10100000 => 'Professional', 10250000 => 'Enterprise', ); } /** * Convert network group names to a css class name. */ function dfrapi_group_name_to_css( $group ) { if ( is_string( $group ) ) { return strtolower( str_replace( array( " ", "-", "." ), "", $group ) ); } elseif ( is_array( $group ) ) { $name = str_replace( array( " ", "-", "." ), "", $group['group'] ); $type = ( $group['type'] == 'coupons' ) ? '_coupons' : ''; return strtolower( $name . $type ); } } /** * Adds global "support" content to "Help" tabs for all Datafeedr plugins. */ function dfrapi_help_tab( $screen ) { $screen->add_help_tab( array( 'id' => 'dfrapi_support_tab', 'title' => __( 'Support', DFRAPI_DOMAIN ), 'content' => '

' . __( "Datafeedr Support", DFRAPI_DOMAIN ) . '

' . '

' . sprintf(__( 'If you have a question or a problem, please search the documentation and the support forums', DFRAPI_DOMAIN ), DFRAPI_DOCS_URL, DFRAPI_QNA_URL ) . '. ' . __( 'If you are still unable to find an answer feel free to contact us using the links below.', DFRAPI_DOMAIN ) . '

' . '

' . __( 'Post a Question', DFRAPI_DOMAIN ) . ' (' . __( 'recommended', DFRAPI_DOMAIN ) . ')

' . '

' . __( 'Email Us', DFRAPI_DOMAIN ) . '

' ) ); $screen->add_help_tab( array( 'id' => 'dfrapi_bug_tab', 'title' => __( 'Found a bug?', DFRAPI_DOMAIN ), 'content' => '

' . __( "Found a bug?", DFRAPI_DOMAIN ) . '

' . '

' . sprintf( __( 'If you find a bug within Datafeedr please see if it\'s already been reported in Bug Reports. If it\'s a new bug, please be as descriptive as possible when reporting a bug.', DFRAPI_DOMAIN ), DFRAPI_BUG_REPORTS_URL ) . '

' . '

' . __( 'Report a bug', DFRAPI_DOMAIN ) . '

' ) ); $screen->set_help_sidebar( '

' . __( 'For more information:', DFRAPI_DOMAIN ) . '

' . '

' . __( 'About Datafeedr', DFRAPI_DOMAIN ) . '

' . '

' . __( 'Datafeedr API Keys', DFRAPI_DOMAIN ) . '

' ); return $screen; }