users can simply execute code


Warning: Illegal string offset 'id' in /var/www/u1153944/data/www/demo.wpfronteditor.com/wp-content/plugins/front-editor-premium/inc/Editor.php on line 36

Warning: Illegal string offset 'id' in /var/www/u1153944/data/www/demo.wpfronteditor.com/wp-content/plugins/front-editor-premium/inc/Editor.php on line 38

Warning: Illegal string offset 'id' in /var/www/u1153944/data/www/demo.wpfronteditor.com/wp-content/plugins/front-editor-premium/inc/Editor.php on line 65
 __('Display', 'front-editor'),
			'require' => __('Display and require', 'front-editor'),
			'disable' => __('Disable this field', 'front-editor')
		];

		add_action(
			'admin_menu',
			function () {

				if (current_user_can('manage_options')) {
					add_menu_page(
						$page_title = __('Front Editor', 'front-editor'),
						$menu_title = __('Front Editor', 'front-editor'),
						$capability = 'manage_options',
						$menu_slug = 'front_editor_settings',
						$function = [__CLASS__, 'display_page'],
						$icon = FE_PLUGIN_URL . '/assets/img/logo.svg',
						'57.5'
					);
				}
			}
		);

		add_action('admin_init', [__CLASS__, 'settings_general'], $priority = 10, $accepted_args = 1);

		/**
		 * checking is front editor page is created
		 */
		add_action('bfe_front_editor_settings_before_form', [__CLASS__, 'add_front_editor_page_check'], 10);

		/**
		 * short information and instruction
		 */
		add_action('bfe_front_editor_settings_before_form', [__CLASS__, 'short_information_and_instruction']);
	}

	/**
	 * adding general settings
	 *
	 * @return void
	 */
	public static function settings_general()
	{
		add_settings_section('bfe_front_editor_general_settings_section', __('Global settings', 'front-editor'), null, 'front_editor_settings');

		/**
		 * Edit button position in single post
		 */
		$cs_option_name = 'bfe_front_editor_edit_button_position';
		register_setting('front_editor_settings', $cs_option_name);
		add_settings_field(
			$id = $cs_option_name,
			$title = __('Edit button position in single post', 'front-editor'),
			$callback = [__CLASS__, 'edit_button_position'],
			$page = 'front_editor_settings',
			$section = 'bfe_front_editor_general_settings_section',
			$args = [
				'id' => $cs_option_name,
				'label_for' => $cs_option_name
			]
		);

		/**
		 * Disable or enable wp admin bar
		 */
		$cs_option_name = 'bfe_front_editor_wp_admin_menu';
		register_setting('front_editor_settings', $cs_option_name);
		add_settings_field(
			$id = $cs_option_name,
			$title = __('WordPress admin bar', 'front-editor'),
			$callback = [__CLASS__, 'wp_admin_menu'],
			$page = 'front_editor_settings',
			$section = 'bfe_front_editor_general_settings_section',
			$args = [
				'id' => $cs_option_name,
				'label_for' => $cs_option_name
			]
		);
	}

	/**
	 * if the page with editor is not set
	 *
	 * @return void
	 */
	public static function add_front_editor_page_check()
	{
		$is_set_editor_page = Editor::get_editor_page_link();
		if (!$is_set_editor_page) {
			$class = 'notice notice-error';
			$message = sprintf(
				__('We cant fined the page with Front Editor, 
			 		please add the page with Gutenberg block named %s
			 		or add Shortcode %s', 'front-editor'),
				$guthenber_block = 'Editor Block',
				$shortcode = '

You do not have permission to edit this post

' ); printf('%2$s', esc_attr($class), $message); } } /** * What we have * * @return void */ public static function short_information_and_instruction() { printf('%s', __('Short information', 'front-editor')); $class = 'notice notice-warning is-dismissible'; $message = sprintf( __( 'If you have some ideas or questions please contact me. The contact information you can find on our website %s', 'front-editor' ),'wpfronteditor.com'); printf('%2$s', esc_attr($class), $message); $github_link = 'GitHub'; $site_link = 'https://wpfronteditor.com/'; printf( '%s', sprintf(__('You can buy pro version or find additional information here or add some ideas or issues in %s', 'front-editor'), $site_link, $github_link) ); } /** * Display UI */ public static function display_page() { echo sprintf('%s', __('Settings Page', 'front-editor')); do_action('bfe_front_editor_settings_before_form'); echo ''; settings_fields('front_editor_settings'); do_settings_sections('front_editor_settings'); submit_button(); echo ''; } /** * post need approvement * * @param [type] $val * @return void */ public static function edit_button_position($val) { $id = $val['id']; echo sprintf('', $id); $options = [ 'left_bottom' => __('Left bottom', 'front-editor'), 'left_top' => __('Left top', 'front-editor'), 'right_bottom' => __('Right bottom', 'front-editor'), 'right_top' => __('Right top', 'front-editor'), ]; foreach ($options as $val => $option) { echo sprintf('%s', $val, selected($val, get_option($id), false), $option); } echo ''; } /** * Display featured image * * @param [type] $val * @return void */ public static function wp_admin_menu($val) { $id = $val['id']; echo sprintf('', $id); $options = [ 'display' => __('Display', 'front-editor'), 'disable' => __('Disable for all', 'front-editor'), 'disable_but_admin' => __('Disable for all but admin', 'front-editor'), ]; foreach ($options as $val => $option) { echo sprintf('%s', $val, selected($val, get_option($id), false), $option); } echo ''; } /** * category selector settings * * @param [type] $val * @return void */ public static function display_category_selector($val) { $disabled = 0; $id = $val['id']; echo sprintf('', $id, disabled($disabled, true, false)); $data = get_option($id); foreach (self::$default_select as $val => $option) { echo sprintf('%s', $val, selected($val, get_option($id), false), $option); } echo ''; } /** * post type selector settings * * @param [type] $val * @return void */ public static function display_post_type_selector($val) { $disabled = 1; if (self::$is_pro_version) { $disabled = 0; } $id = $val['id']; echo sprintf('', $id, disabled($disabled, true, false)); $data = get_option($id); foreach (self::$default_select as $val => $option) { echo sprintf('%s', $val, selected($val, get_option($id), false), $option); } echo ''; if ($disabled) { echo sprintf('%s', self::$only_if_pro_text); } } } MenuSettings::init();

Leave a Comment