',
esc_attr( $button['class'] ),
esc_attr( $button['type'] ),
esc_attr( $button['label'] )
);
}
return $buttons_html;
}
/**
* Content of the bottom row of the header.
*
* @return void
*/
public function output_header_bottom() {
$add_new_url = $this->admin_url( 'admin.php?page=wpcode-snippet-manager' );
?>
get_snippet_type_buttons(); ?>
0 ) {
$notice = sprintf( /* translators: %d - Activated snippets count. */
_n( '%d snippet was successfully activated.', '%d snippets were successfully activated.', $count, 'insert-headers-and-footers' ),
$count
);
}
if ( isset( $_GET['error'] ) ) {
$error_count = absint( $_GET['error'] );
$notice .= ' ';
$notice .= sprintf( /* translators: %d - Failed to activate snippets count. */
_n( '%d snippet was not activated due to an error.', '%d snippets were not activated due to errors.', $error_count, 'insert-headers-and-footers' ),
$error_count
);
}
}
if ( ! empty( $_GET['disabled'] ) ) {
$count = absint( $_GET['disabled'] );
$notice = sprintf( /* translators: %d - Deactivated snippets count. */
_n( '%d snippet was successfully deactivated.', '%d snippets were successfully deactivated.', $count, 'insert-headers-and-footers' ),
$count
);
}
// phpcs:enable WordPress.Security.NonceVerification
if ( isset( $error_count ) && isset( $notice ) ) {
$this->set_error_message( $notice );
} elseif ( isset( $notice ) ) {
$this->set_success_message( $notice );
}
}
/**
* On the deactivated snippets view, show a notice explaining that this view shows the snippets that have been
* automatically disabled due to throwing an error and highlight the error logging option, if disabled.
*
* @return void
*/
public function maybe_show_deactivated_notice() {
if ( ! isset( $_GET['view'] ) || 'has_error' !== $_GET['view'] ) { // phpcs:ignore WordPress.Security.NonceVerification
return;
}
// Let's see if error logging is enabled.
$logging_enabled = wpcode()->settings->get_option( 'error_logging' );
$button_text = esc_html__( 'Enable Error Logging', 'insert-headers-and-footers' );
$button_url = add_query_arg(
array(
'page' => 'wpcode-settings',
'view' => 'errors',
),
$this->admin_url( 'admin.php' )
);
?>
esc_html__( 'Number of snippets per page:', 'insert-headers-and-footers' ),
'option' => 'wpcode_snippets_per_page',
'default' => 20,
)
);
}
/**
* Hide the last updated column by default.
*
* @param array $hidden The hidden columns.
* @param WP_Screen $screen The current screen.
*
* @return mixed
*/
public function hide_columns( $hidden, $screen ) {
$hidden[] = 'updated';
$hidden[] = 'id';
$hidden[] = 'shortcode';
$hidden[] = 'code_type';
return $hidden;
}
/**
* Prepare the data for the admin JS localization.
*
* @param array $data The data to be localized.
*
* @return array
*/
public function prepare_admin_js_localization_data( $data ) {
$data['blocks_title'] = __( 'Blocks snippets is a Pro Feature', 'insert-headers-and-footers' );
$data['blocks_description'] = __( 'Upgrade to PRO today and unlock building snippets using the Gutenberg Block Editor. Create templates using blocks and use the full power of WPCode to insert them in your site.', 'insert-headers-and-footers' );
$data['blocks_snippet_upgrade_url'] = wpcode_utm_url( 'https://wpcode.com/lite/', 'code_type', 'blocks', 'modal' );
$data['button_text'] = __( 'Upgrade to PRO', 'insert-headers-and-footers' );
$data['scss_title'] = __( 'SCSS snippets is a Pro Feature', 'insert-headers-and-footers' );
$data['scss_description'] = __( 'Upgrade to PRO today and unlock editing snippets using SCSS code with optimized compiling directly in the WordPress admin.', 'insert-headers-and-footers' );
$data['scss_snippet_upgrade_url'] = wpcode_utm_url( 'https://wpcode.com/lite/', 'code_type', 'scss', 'modal' );
return $data;
}
/**
*
* @param string $screen_settings Screen settings.
* @param WP_Screen $screen WP_Screen object.
*
* @return string
*/
public function add_custom_screen_option( $screen_settings, $screen ) {
$order_by = get_user_option( 'wpcode_snippets_order_by' );
$order = get_user_option( 'wpcode_snippets_order' );
if ( empty( $order_by ) ) {
$order_by = 'ID';
}
if ( empty( $order ) ) {
$order = 'desc';
}
// Pick which column to order by, title, date or last updated using a select.
$screen_settings .= '
';
$screen_settings .= '';
return $screen_settings;
}
/**
* Remove the duplicated parameter from the URL.
*
* @param array $args The arguments that should be removed from the URL.
*
* @return array
*/
public function remove_query_arg_from_url( $args ) {
$args[] = 'duplicated';
return $args;
}
}