%2$s', 'https://docs.presscustomizr.com/article/337-getting-started-with-the-nimble-builder-plugin', __('Docs', 'text-doma') );
array_unshift($links, $doc_link );
$settings_link = sprintf('
%2$s',
add_query_arg( array( 'tab' => 'options' ), admin_url( NIMBLE_OPTIONS_PAGE_URL ) ),
__('Settings', 'text-doma')
);
array_unshift($links, $settings_link );
return $links;
}
add_filter("plugin_action_links_".plugin_basename(NIMBLE_PLUGIN_FILE), '\Nimble\nb_settings_link' );
/* ------------------------------------------------------------------------- *
* SAVE OPTION HOOK + CUSTOMIZABLE REDIRECTION
/* ------------------------------------------------------------------------- */
// fired @'admin_post'
function nb_save_options() {
do_action('nb_admin_post');
//wp_safe_redirect( urldecode( admin_url( NIMBLE_OPTIONS_PAGE_URL ) ) );
nb_admin_redirect();
}
add_action( 'admin_post', '\Nimble\nb_save_options' );
// fired @'admin_post'
function nb_admin_redirect() {
$url = sanitize_text_field(
wp_unslash( $_POST['_wp_http_referer'] ) // Input var okay.
);
// Default option url : urldecode( admin_url( NIMBLE_OPTIONS_PAGE_URL ) )
$url = urldecode( $url );
$url = empty($url) ? urldecode( admin_url( NIMBLE_OPTIONS_PAGE_URL ) ) : $url;
// Finally, redirect back to the admin page.
// Note : filter 'nimble_admin_redirect_url' is used in NB pro to add query params used to display warning/error messages
wp_safe_redirect( apply_filters('nimble_admin_redirect_url', $url ) );
exit;
}
// @return bool
function nb_has_valid_nonce( $option_group = 'nb-options-save', $nonce = 'nb-options-nonce' ) {
// If the field isn't even in the $_POST, then it's invalid.
if ( !isset( $_POST[$nonce] ) ) { // Input var okay.
return false;
}
return wp_verify_nonce( wp_unslash( $_POST[$nonce] ), $option_group );
}
/* ------------------------------------------------------------------------- *
* REGISTER TABS
/* ------------------------------------------------------------------------- */
Nimble_Manager()->admin_option_tabs = array();
// @return void
function nb_register_option_tab( $tab ) {
$tab = wp_parse_args( $tab, array(
'id' => '',
'title' => '',
'page_title' => '',
'content' => '',
));
Nimble_Manager()->admin_option_tabs[$tab['id']] = $tab;
}
function nb_get_active_option_tab() {
// check that we have a tab param and that this tab is registered
$tab_id = isset( $_GET['tab'] ) ? sanitize_text_field($_GET['tab']) : 'welcome';
if ( !array_key_exists( $tab_id, Nimble_Manager()->admin_option_tabs ) ) {
sek_error_log( __FUNCTION__ . ' error => invalid tab');
$tab_id = 'welcome';
}
return $tab_id;
}
/* ------------------------------------------------------------------------- *
* WELCOME PAGE
/* ------------------------------------------------------------------------- */
nb_register_option_tab([
'id' => 'welcome',
'title' => __('Welcome', 'text-doma'),
'page_title' => __('Nimble Builder', 'nimble' ),
'content' => '\Nimble\print_welcome_page',
]);
function print_welcome_page() {
?>
$nb_cpt,
'post_status' => get_post_stati(),
'posts_per_page' => -1,
'no_found_rows' => true,
'cache_results' => true,
'update_post_meta_cache' => false,
'update_post_term_cache' => false,
'lazy_load_term_meta' => false,
)
);
if ( !is_array( $query->posts ) || empty( $query->posts ) ) {
continue;
}
foreach ( $query->posts as $post_object ) {
//permanently delete post ( unlike wp_trash_post() )
wp_delete_post($post_object->ID);
}
}
// Nimble options
$nb_opts = [
'NIMBLE_OPT_SEKTION_POST_INDEX',
'NIMBLE_OPT_NAME_FOR_GLOBAL_OPTIONS',
'NIMBLE_OPT_FOR_MODULE_CSS_READING_STATUS',
'NIMBLE_OPT_NAME_FOR_MOST_USED_FONTS',
'NIMBLE_OPT_FOR_GLOBAL_CSS',
'NIMBLE_OPT_NAME_FOR_SECTION_JSON',
'NIMBLE_OPT_NAME_FOR_BACKWARD_FIXES',
// admin options
'NIMBLE_OPT_NAME_FOR_SHORTCODE_PARSING',
'NIMBLE_OPT_NAME_FOR_DEBUG_MODE'
];
foreach( $nb_opts as $opt_name ) {
if ( !defined( $opt_name ) )
continue;
$opt_name = constant($opt_name);
delete_option( $opt_name );
}
// clean other options like : nimble_start_date, nimble_started_with_version, nimble_version,
foreach( [
'nimble_start_date',
'nimble_started_with_version',
'nimble_version_upgraded_from',
'nimble_version',
'nimble_last_update_notice',
'__nimble_options__'//<= deprecated option name
] as $opt_name ) {
delete_option( $opt_name );
}
// clean options like nimble___skp__post_page_1010 ( old way to map skope_id and skoped post )
sek_clean_options_starting_like( 'nimble___');
sek_clean_options_starting_like( 'nimblebuilder_pro_');
// Nimble transients
$nb_transients = [
'NIMBLE_FEEDBACK_NOTICE_ID',
'NIMBLE_FAWESOME_TRANSIENT_ID',
'NIMBLE_GFONTS_TRANSIENT_ID',
'NIMBLE_FEEDBACK_STATUS_TRANSIENT_ID',
'NIMBLE_API_CHECK_TRANSIENT_ID'
];
foreach( $nb_transients as $trans_id ) {
if ( !defined( $trans_id ) )
continue;
$trans_id = constant($trans_id);
delete_transient( $trans_id );
}
// => remove all other transients
sek_clean_transients_like( 'nimble_' );//'nimble_api_posts', 'nimble_api_tmpl_' . $tmpl_name
sek_clean_transients_like( 'nimble_preset_sections_' );//old transient for storing preset sections. Now fetched remotely. See #802
sek_clean_transients_like( 'section_params_transient' );//old transient that may still be there
sek_clean_transients_like( 'section_params_transient' );//old transient that may still be there
// Nimble CSS stylesheets
$css_dir_list = [ 'NIMBLE_DEPREC_ONE_CSS_FOLDER_NAME', 'NIMBLE_DEPREC_TWO_CSS_FOLDER_NAME', 'NIMBLE_CSS_FOLDER_NAME' ];
global $wp_filesystem;
require_once ( ABSPATH . '/wp-admin/includes/file.php' );
WP_Filesystem();
$upload_dir = wp_get_upload_dir();
foreach( $css_dir_list as $css_dir ) {
if ( !defined( $css_dir ) )
continue;
$css_dir = constant( $css_dir );
if ( is_multisite() ) {
$site = get_site();
$network_id = $site->site_id;
$site_id = $site->blog_id;
$css_dir = trailingslashit( $css_dir ) . trailingslashit( $network_id ) . $site_id;
}
$folder_path = wp_normalize_path( trailingslashit( $upload_dir['basedir'] ) . $css_dir );
if ( $wp_filesystem->exists( $folder_path ) ) {
$wp_filesystem->rmdir( $folder_path, true );
}
}
return 'success';
}
/* ------------------------------------------------------------------------- *
* OPTIONS PAGE
/* ------------------------------------------------------------------------- */
nb_register_option_tab([
'id' => 'options',
'title' => __('Options', 'text-doma'),
'page_title' => __('Nimble Builder Options', 'nimble' ),
'content' => '\Nimble\print_options_page',
]);
function print_options_page() {
?>
%2$s',
NIMBLE_BASE_URL.'/assets/czr/sek/img/pro_orange.svg?ver='.NIMBLE_VERSION,
__('Manage authorized users', 'nimble' )
);
}
nb_register_option_tab([
'id' => 'restrict_users',
'title' => $restrict_users_title,
'page_title' => __('Manage authorized users', 'nimble' ),
'content' => '\Nimble\print_restrict_users_options_content',
]);
function print_restrict_users_options_content() {
if ( !sek_is_pro() ) {
?>
'system-info',
'title' => __('System info', 'text-doma'),
'page_title' => __('System info', 'nimble' ),
'content' => '\Nimble\print_system_info',
]);
function print_system_info() {
require_once( NIMBLE_BASE_PATH . '/inc/admin/system-info.php' );
?>
'doc',
'title' => __('Documentation', 'text-doma'),
'page_title' => __('Nimble Builder knowledge base', 'nimble' ),
'content' => '\Nimble\print_doc_page',
]);
function print_doc_page() {
?>