Edit File by line
/home/zeestwma/ajeebong.../wp-conte.../plugins/code-sni.../php
File: class-contextual-help.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Code_Snippets;
[2] Fix | Delete
[3] Fix | Delete
use WP_Screen;
[4] Fix | Delete
[5] Fix | Delete
/**
[6] Fix | Delete
* This file holds all the content for the contextual help screens.
[7] Fix | Delete
*
[8] Fix | Delete
* @package Code_Snippets
[9] Fix | Delete
*/
[10] Fix | Delete
class Contextual_Help {
[11] Fix | Delete
[12] Fix | Delete
/**
[13] Fix | Delete
* Current screen object
[14] Fix | Delete
*
[15] Fix | Delete
* @see get_current_screen()
[16] Fix | Delete
*
[17] Fix | Delete
* @var WP_Screen
[18] Fix | Delete
*/
[19] Fix | Delete
public WP_Screen $screen;
[20] Fix | Delete
[21] Fix | Delete
/**
[22] Fix | Delete
* Name of current screen
[23] Fix | Delete
*
[24] Fix | Delete
* @see get_current_screen()
[25] Fix | Delete
*
[26] Fix | Delete
* @var string
[27] Fix | Delete
*/
[28] Fix | Delete
public string $screen_name;
[29] Fix | Delete
[30] Fix | Delete
/**
[31] Fix | Delete
* Class constructor
[32] Fix | Delete
*
[33] Fix | Delete
* @param string $screen_name Name of current screen.
[34] Fix | Delete
*/
[35] Fix | Delete
public function __construct( string $screen_name ) {
[36] Fix | Delete
$this->screen_name = $screen_name;
[37] Fix | Delete
}
[38] Fix | Delete
[39] Fix | Delete
/**
[40] Fix | Delete
* Load the contextual help
[41] Fix | Delete
*/
[42] Fix | Delete
public function load() {
[43] Fix | Delete
$this->screen = get_current_screen();
[44] Fix | Delete
[45] Fix | Delete
switch ( $this->screen_name ) {
[46] Fix | Delete
case 'manage':
[47] Fix | Delete
$this->load_manage_help();
[48] Fix | Delete
break;
[49] Fix | Delete
[50] Fix | Delete
case 'edit':
[51] Fix | Delete
$this->load_edit_help();
[52] Fix | Delete
break;
[53] Fix | Delete
[54] Fix | Delete
case 'import':
[55] Fix | Delete
$this->load_import_help();
[56] Fix | Delete
break;
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
$this->load_help_sidebar();
[60] Fix | Delete
}
[61] Fix | Delete
[62] Fix | Delete
/**
[63] Fix | Delete
* Load the help sidebar
[64] Fix | Delete
*/
[65] Fix | Delete
private function load_help_sidebar() {
[66] Fix | Delete
$sidebar_links = [
[67] Fix | Delete
'https://wordpress.org/plugins/code-snippets' => __( 'About Plugin', 'code-snippets' ),
[68] Fix | Delete
'https://codesnippets.pro/docs/faq/' => __( 'FAQ', 'code-snippets' ),
[69] Fix | Delete
'https://wordpress.org/support/plugin/code-snippets' => __( 'Support Forum', 'code-snippets' ),
[70] Fix | Delete
'https://codesnippets.pro' => __( 'Plugin Website', 'code-snippets' ),
[71] Fix | Delete
];
[72] Fix | Delete
[73] Fix | Delete
$kses = [
[74] Fix | Delete
'p' => [],
[75] Fix | Delete
'strong' => [],
[76] Fix | Delete
'a' => [ 'href' => [] ],
[77] Fix | Delete
];
[78] Fix | Delete
[79] Fix | Delete
$contents = sprintf( "<p><strong>%s</strong></p>\n", esc_html__( 'For more information:', 'code-snippets' ) );
[80] Fix | Delete
[81] Fix | Delete
foreach ( $sidebar_links as $url => $label ) {
[82] Fix | Delete
$contents .= "\n" . sprintf( '<p><a href="%s">%s</a></p>', esc_url( $url ), esc_html( $label ) );
[83] Fix | Delete
}
[84] Fix | Delete
[85] Fix | Delete
$this->screen->set_help_sidebar( wp_kses( $contents, $kses ) );
[86] Fix | Delete
}
[87] Fix | Delete
[88] Fix | Delete
/**
[89] Fix | Delete
* Add a help tab to the current screen.
[90] Fix | Delete
*
[91] Fix | Delete
* @param string $id Screen ID.
[92] Fix | Delete
* @param string $title Screen title.
[93] Fix | Delete
* @param string|array<string> $paragraphs List of paragraphs to display as content.
[94] Fix | Delete
*
[95] Fix | Delete
* @return void
[96] Fix | Delete
*/
[97] Fix | Delete
private function add_help_tab( string $id, string $title, $paragraphs ) {
[98] Fix | Delete
$this->screen->add_help_tab(
[99] Fix | Delete
array(
[100] Fix | Delete
'title' => $title,
[101] Fix | Delete
'id' => $id,
[102] Fix | Delete
'content' => wp_kses_post(
[103] Fix | Delete
implode(
[104] Fix | Delete
"\n",
[105] Fix | Delete
array_map(
[106] Fix | Delete
function ( $content ) {
[107] Fix | Delete
return '<p>' . $content . '</p>';
[108] Fix | Delete
},
[109] Fix | Delete
is_array( $paragraphs ) ? $paragraphs : [ $paragraphs ]
[110] Fix | Delete
)
[111] Fix | Delete
)
[112] Fix | Delete
),
[113] Fix | Delete
)
[114] Fix | Delete
);
[115] Fix | Delete
}
[116] Fix | Delete
[117] Fix | Delete
/**
[118] Fix | Delete
* Reusable introduction text
[119] Fix | Delete
*
[120] Fix | Delete
* @return string
[121] Fix | Delete
*/
[122] Fix | Delete
private function get_intro_text(): string {
[123] Fix | Delete
return __( 'Snippets are similar to plugins - they both extend and expand the functionality of WordPress. Snippets are more light-weight, just a few lines of code, and do not put as much load on your server. ', 'code-snippets' );
[124] Fix | Delete
}
[125] Fix | Delete
[126] Fix | Delete
/**
[127] Fix | Delete
* Register and handle the help tabs for the manage snippets admin page
[128] Fix | Delete
*/
[129] Fix | Delete
private function load_manage_help() {
[130] Fix | Delete
$this->add_help_tab(
[131] Fix | Delete
'overview',
[132] Fix | Delete
__( 'Overview', 'code-snippets' ),
[133] Fix | Delete
$this->get_intro_text() .
[134] Fix | Delete
__( 'Here you can manage your existing snippets and perform tasks on them such as activating, deactivating, deleting and exporting.', 'code-snippets' )
[135] Fix | Delete
);
[136] Fix | Delete
[137] Fix | Delete
$this->add_help_tab(
[138] Fix | Delete
'safe-mode',
[139] Fix | Delete
__( 'Safe Mode', 'code-snippets' ),
[140] Fix | Delete
[
[141] Fix | Delete
__( 'Be sure to check your snippets for errors before you activate them, as a faulty snippet could bring your whole blog down. If your site starts doing strange things, deactivate all your snippets and activate them one at a time.', 'code-snippets' ),
[142] Fix | Delete
__( "If something goes wrong with a snippet, and you can't use WordPress, you can cause all snippets to stop executing by turning on <strong>safe mode</strong>.", 'code-snippets' ),
[143] Fix | Delete
/* translators: %s: URL to Code Snippets Pro Docs */
[144] Fix | Delete
sprintf( __( 'You can find out how to enable safe mode in the <a href="%s">Code Snippets Pro Docs</a>.', 'code-snippets' ), 'https://codesnippets.pro/doc/safe-mode/' ),
[145] Fix | Delete
]
[146] Fix | Delete
);
[147] Fix | Delete
}
[148] Fix | Delete
[149] Fix | Delete
/**
[150] Fix | Delete
* Register and handle the help tabs for the single snippet admin page
[151] Fix | Delete
*/
[152] Fix | Delete
private function load_edit_help() {
[153] Fix | Delete
$this->add_help_tab(
[154] Fix | Delete
'overview',
[155] Fix | Delete
__( 'Overview', 'code-snippets' ),
[156] Fix | Delete
[
[157] Fix | Delete
$this->get_intro_text() .
[158] Fix | Delete
__( 'Here you can add a new snippet, or edit an existing one.', 'code-snippets' ),
[159] Fix | Delete
/* translators: %s: URL to Code Snippets Pro Docs */
[160] Fix | Delete
sprintf( __( "If you're not sure about the types of snippets you can add, take a look at the <a href=\"%s\">Code Snippets Pro Docs</a> for inspiration.", 'code-snippets' ), 'https://codesnippets.pro/docs/adding-snippets/' ),
[161] Fix | Delete
]
[162] Fix | Delete
);
[163] Fix | Delete
[164] Fix | Delete
$this->add_help_tab(
[165] Fix | Delete
'adding',
[166] Fix | Delete
__( 'Adding Snippets', 'code-snippets' ),
[167] Fix | Delete
[
[168] Fix | Delete
__( 'You need to fill out the name and code fields for your snippet to be added. While the description field will add more information about how your snippet works, what is does and where you found it, it is completely optional.', 'code-snippets' ),
[169] Fix | Delete
__( 'Please be sure to check that your snippet is valid PHP code and will not produce errors before adding it through this page. While doing so will not become active straight away, it will help to minimize the chance of a faulty snippet becoming active on your site.', 'code-snippets' ),
[170] Fix | Delete
]
[171] Fix | Delete
);
[172] Fix | Delete
}
[173] Fix | Delete
[174] Fix | Delete
/**
[175] Fix | Delete
* Register and handle the help tabs for the import snippets admin page
[176] Fix | Delete
*/
[177] Fix | Delete
private function load_import_help() {
[178] Fix | Delete
$manage_url = code_snippets()->get_menu_url( 'manage' );
[179] Fix | Delete
[180] Fix | Delete
$this->add_help_tab(
[181] Fix | Delete
'overview',
[182] Fix | Delete
__( 'Overview', 'code-snippets' ),
[183] Fix | Delete
$this->get_intro_text() .
[184] Fix | Delete
__( 'Here you can load snippets from a code snippets export file into the database alongside existing snippets.', 'code-snippets' )
[185] Fix | Delete
);
[186] Fix | Delete
[187] Fix | Delete
$this->add_help_tab(
[188] Fix | Delete
'import',
[189] Fix | Delete
__( 'Importing', 'code-snippets' ),
[190] Fix | Delete
__( 'You can load your snippets from a code snippets export file using this page.', 'code-snippets' ) .
[191] Fix | Delete
/* translators: %s: URL to Snippets admin menu */
[192] Fix | Delete
sprintf( __( 'Imported snippets will be added to the database along with your existing snippets. Regardless of whether the snippets were active on the previous site, imported snippets are always inactive until activated using the <a href="%s">Manage Snippets</a> page.', 'code-snippets' ), $manage_url )
[193] Fix | Delete
);
[194] Fix | Delete
[195] Fix | Delete
$this->add_help_tab(
[196] Fix | Delete
'export',
[197] Fix | Delete
__( 'Exporting', 'code-snippets' ),
[198] Fix | Delete
/* translators: %s: URL to Manage Snippets admin menu */
[199] Fix | Delete
sprintf( __( 'You can save your snippets to a code snippets export file using the <a href="%s">Manage Snippets</a> page.', 'code-snippets' ), $manage_url )
[200] Fix | Delete
);
[201] Fix | Delete
}
[202] Fix | Delete
}
[203] Fix | Delete
[204] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function