ajaxHandler();
die;
}
function admin_menu() {
add_menu_page(
__( 'Datafeedr API', DFRAPI_DOMAIN ),
__( 'Datafeedr API', DFRAPI_DOMAIN ),
'manage_options',
'dfrapi',
'',
null,
42
);
}
function networks_menu() {
add_submenu_page(
'dfrapi',
__( 'Networks — Datafeedr API', DFRAPI_DOMAIN ),
__( 'Networks', DFRAPI_DOMAIN ),
'manage_options',
'dfrapi_networks',
array( $this, 'networks_output' )
);
}
public function networks_output() {
$key = 'dfrapi_networks';
$page = 'dfrapi-networks';
echo '
';
echo '
' . dfrapi_setting_pages( $page ) . ' — Datafeedr API
';
echo '
';
echo '
' .
__( 'You have unsaved changes', DFRAPI_DOMAIN ) .
'
';
echo '
';
}
function merchants_menu() {
add_submenu_page(
'dfrapi',
__( 'Merchants — Datafeedr API', DFRAPI_DOMAIN ),
__( 'Merchants', DFRAPI_DOMAIN ),
'manage_options',
'dfrapi_merchants',
array( $this, 'merchants_output' )
);
}
function merchants_output() {
$key = 'dfrapi_merchants';
$page = 'dfrapi-merchants';
echo '';
echo '
' . dfrapi_setting_pages( $page ) . ' — Datafeedr API
';
echo '
';
echo '
' .
__( 'You have unsaved changes', DFRAPI_DOMAIN ) . '
';
echo '
';
}
function initialize_classes() {
new Dfrapi_Configuration();
// Show "Networks" page if API keys are present.
if ( Dfrapi_Env::api_keys_exist() ) {
if ( is_admin() && isset( $_GET['page'] ) && 'dfrapi_networks' == $_GET['page'] ) {
new Dfrapi_Networks();
}
if ( is_admin() && isset( $_POST['option_page'] ) && ( 'dfrapi-networks' == $_POST['option_page'] ) ) {
new Dfrapi_Networks();
}
}
// Show "Merchants" page if API keys are present AND a network is selected.
if ( Dfrapi_Env::api_keys_exist() && Dfrapi_Env::network_is_selected() ) {
if ( is_admin() && isset( $_GET['page'] ) && 'dfrapi_merchants' == $_GET['page'] ) {
new Dfrapi_Merchants();
}
if ( is_admin() && isset( $_POST['option_page'] ) && ( 'dfrapi-merchants' == $_POST['option_page'] ) ) {
new Dfrapi_Merchants();
}
}
// Show Tools, Export and Import pages if API keys are present.
if ( Dfrapi_Env::api_keys_exist() ) {
new Dfrapi_Tools();
new Dfrapi_Export();
new Dfrapi_Import();
new Dfrapi_Account();
}
}
function load_css() {
// Basic styling for API pages.
wp_register_style( 'dfrapi_css', DFRAPI_URL . 'css/style.css', false, DFRAPI_VERSION );
wp_enqueue_style( 'dfrapi_css' );
// Basic styling for API pages.
wp_register_style( 'dfrapi_searchform', DFRAPI_URL . 'css/searchform.css', false, DFRAPI_VERSION );
wp_enqueue_style( 'dfrapi_searchform' );
}
function load_js() {
wp_register_script( 'dfrapi_general_js', DFRAPI_URL.'js/general.js', array( 'jquery' ), DFRAPI_VERSION, true );
wp_enqueue_script( 'dfrapi_general_js' );
wp_register_script( 'dfrapi_searchfilter_js', DFRAPI_URL.'js/searchfilter.js', array( 'jquery' ), DFRAPI_VERSION, false );
wp_enqueue_script( 'dfrapi_searchfilter_js' );
wp_register_script( 'dfrapi_merchants_js', DFRAPI_URL.'js/merchants.js', array( 'jquery' ), DFRAPI_VERSION, false );
wp_enqueue_script( 'dfrapi_merchants_js' );
wp_register_script( 'dfrapi_searchform_js', DFRAPI_URL.'js/searchform.js', array( 'jquery' ), DFRAPI_VERSION, false );
wp_enqueue_script( 'dfrapi_searchform_js' );
wp_register_script( 'dfrapi_jquery_reveal_js', DFRAPI_URL.'js/jquery.reveal.js', array( 'jquery' ), DFRAPI_VERSION, false );
wp_enqueue_script( 'dfrapi_jquery_reveal_js' );
}
function admin_notices() {
$dfrapi_env = new Dfrapi_Env();
if ( $notices = get_option( 'dfrapi_admin_notices' ) ) {
foreach ( $notices as $key => $message ) {
$button = ( $message['url'] != '' ) ? dfrapi_fix_button( $message['url'], $message['button_text'] ) : '';
$upgrade_account = ( $key == 'usage_over_90_percent' ) ? ' | ' . __( 'Upgrade', DFRAPI_DOMAIN ) . '' : '';
echo ''.$message['message'].$button.$upgrade_account.'
';
}
delete_option( 'dfrapi_admin_notices' );
}
}
function plugin_row_meta( $links, $plugin_file ) {
if ( $plugin_file == DFRAPI_BASENAME ) {
/* $links[] = sprintf( '%s', __( 'Integration Plugins', DFRAPI_DOMAIN ) ); */
$links[] = sprintf( '%s', __( 'Support', DFRAPI_DOMAIN ) );
return $links;
}
return $links;
}
function action_links( $links ) {
return array_merge(
$links,
array(
'config' => '' . __( 'API Settings', DFRAPI_DOMAIN ) . '',
)
);
}
}
$dfrapi_initialize = new Dfrapi_Initialize();
} // class_exists check