' . _x( 'Settings', 'Text for Accountable Press plugin settings link', 'accountable-press' ) . '', admin_url( 'options-general.php?page=accountable-press-settings' ) ); return array_merge( $plugin_actions, $actions ); } add_filter( 'plugin_action_links_' . plugin_basename( ACCOUNTABLE_PRESS_FILE ), 'accountable_press_add_settings_link', 10, 4 ); /** * Add the Accountable Press link to the Settings admin menu. * * @since 1.0.0 */ function accountable_press_add_admin_menu() { add_options_page( __( 'Accountable Press Settings', 'accountable-press' ), __( 'Accountable Press', 'accountable-press' ), 'manage_options', 'accountable-press-settings', 'accountable_press_show_settings_page' ); } add_action( 'admin_menu', 'accountable_press_add_admin_menu' ); /** * Display the Accountable Press settings page. * * @since 1.0.0 */ function accountable_press_show_settings_page() { $account_id = get_option( 'accountable_press_account_id', '' ); include ACCOUNTABLE_PRESS_PATH . 'admin/settings-template.php'; } function accountable_press_save_settings() { if ( isset( $_POST['save_accountable_press_settings'] ) && current_user_can( 'manage_options' ) ) { $nonce = isset( $_POST['_wpnonce'] ) ? sanitize_key( $_POST['_wpnonce'] ) : null; if ( ! wp_verify_nonce( $nonce, 'save_accountable_press_settings' ) ) { $GLOBALS['accountable_press_notice'] = array( 'status' => 'error', 'message' => __( 'Accountable Press settings were not saved because the form has expired. Try again.', 'accountable-press' ) ); return; } $account_id = sanitize_text_field( $_POST['accountable_press_account_id'] ); update_option( 'accountable_press_account_id', $account_id ); $GLOBALS['accountable_press_notice'] = array( 'status' => 'success', 'message' => __( 'Settings saved.', 'accountable-press' ) ); } } add_action( 'admin_init', 'accountable_press_save_settings' ); function accountable_press_settings_message() { if ( isset( $GLOBALS['accountable_press_notice'] ) && is_array( $GLOBALS['accountable_press_notice'] ) ) { ?>