first commit

This commit is contained in:
2024-07-15 11:28:08 +02:00
commit f52d538ea5
21891 changed files with 6161164 additions and 0 deletions

View File

@@ -0,0 +1,120 @@
<?php
/**
* @package akeebabackupwp
* @copyright Copyright (c)2014-2019 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU GPL version 3 or later
*/
$plugin_dir = get_option('akeebabackupwp_plugin_dir', 'akeebabackupwp');
$plugin_path = WP_PLUGIN_DIR . '/' . $plugin_dir;
// Let's double check that the file is at the same version of the component
define('AKEEBABACKUP_MUPLUGIN_COREUPDATE_VERSION', '3.6.1');
if (!defined('AKEEBABACKUP_VERSION'))
{
// No version file? Be safe and stop here
if (!file_exists($plugin_path.'/app/version.php'))
{
return;
}
require_once $plugin_path.'/app/version.php';
}
// This should never happen, but let's be safe than sorry
if (!defined('AKEEBABACKUP_VERSION'))
{
return;
}
if (! version_compare(AKEEBABACKUP_MUPLUGIN_COREUPDATE_VERSION, AKEEBABACKUP_VERSION, 'eq'))
{
// Two different versions? Abort! Abort!
return;
}
// This should never happen, but maybe our code could be triggered by some kind of CLI scripts, so better be safe than sorry
if (!isset($_SERVER['REQUEST_URI']))
{
return;
}
$current_url = $_SERVER['REQUEST_URI'];
// Check we're on the correct page
if (stripos($current_url, 'wp-admin/update-core.php') === false)
{
return;
}
// Missing action or not the action we're looking for
if (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], ['do-core-upgrade', 'do-core-reinstall']))
{
return;
}
// Avoid endless loops
if (isset($_REQUEST['akeeba_autoupdate_ignore']))
{
return;
}
if (!class_exists('AkeebaBackupWP'))
{
require_once WP_PLUGIN_DIR.'/'.$plugin_dir.'/helpers/AkeebaBackupWP.php';
}
$backup_profile = AkeebaBackupWP::getProfileManualCoreUpdate();
// No backup profile means the feature is disabled
if (!$backup_profile)
{
return;
}
if (!function_exists('find_core_update'))
{
require_once ABSPATH . 'wp-admin/includes/update.php';
}
// Do we really have an update to perform?
$version = isset( $_POST['version'] )? $_POST['version'] : false;
$locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
$update = find_core_update( $version, $locale );
if ( !$update )
{
return;
}
$return_url = admin_url().'update-core.php?action='.$_REQUEST['action'].'&akeeba_autoupdate_ignore=1';
$return_form = [
'_wpnonce' => $_POST['_wpnonce'],
'_wp_http_referer' => $_POST['_wp_http_referer'],
'upgrade' => 1,
'version' => $version,
'locale' => $locale
];
$backup_url = admin_url().'admin.php?page='.$plugin_dir.'/akeebabackupwp.php&view=backup&autostart=1&backuponupdate=1';
$backup_url .= '&profile='.$backup_profile;
// Let's use already generated nonce, and tell AWF which action we used to generate it
$backup_url .= '&_wpnonce='.$_POST['_wpnonce'];
$backup_url .= '&_wpaction=upgrade-core';
$backup_url .= '&returnurl='.urlencode($return_url);
$backup_url .= '&returnform='.base64_encode(json_encode($return_form));
if (!headers_sent())
{
header("Location: $backup_url", true, 302);
}
// Let's add a fallback for redirections, in case headers were already sent
echo '<script type="text/javascript">window.location = "'.$backup_url.'"; </script>'."\n";
echo 'If you are not redirected in 10 seconds, please click <a href="'.$backup_url.'">here</a> to take a backup before updating WordPress.';
die();

View File

@@ -0,0 +1,134 @@
<?php
/**
* Plugin Name: Elementor Safe Mode
* Description: Safe Mode allows you to troubleshoot issues by only loading the editor, without loading the theme or any other plugin.
* Plugin URI: https://elementor.com/?utm_source=safe-mode&utm_campaign=plugin-uri&utm_medium=wp-dash
* Author: Elementor.com
* Version: 1.0.0
* Author URI: https://elementor.com/?utm_source=safe-mode&utm_campaign=author-uri&utm_medium=wp-dash
*
* Text Domain: elementor
*
* @package Elementor
* @category Safe Mode
*
* Elementor is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Elementor is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
class Safe_Mode {
const OPTION_ENABLED = 'elementor_safe_mode';
const OPTION_TOKEN = self::OPTION_ENABLED . '_token';
public function is_enabled() {
return get_option( self::OPTION_ENABLED );
}
public function is_valid_token() {
$token = isset( $_COOKIE[ self::OPTION_TOKEN ] ) ? $_COOKIE[ self::OPTION_TOKEN ] : null;
if ( $token && get_option( self::OPTION_TOKEN ) === $token ) {
return true;
}
return false;
}
public function is_requested() {
return ! empty( $_REQUEST['elementor-mode'] ) && 'safe' === $_REQUEST['elementor-mode'];
}
public function is_editor() {
return is_admin() && isset( $_GET['action'] ) && 'elementor' === $_GET['action'];
}
public function is_editor_preview() {
return isset( $_GET['elementor-preview'] );
}
public function is_editor_ajax() {
// PHPCS - There is already nonce verification in the Ajax Manager
return is_admin() && isset( $_POST['action'] ) && 'elementor_ajax' === $_POST['action']; // phpcs:ignore WordPress.Security.NonceVerification.Missing
}
public function add_hooks() {
add_filter( 'pre_option_active_plugins', function () {
return get_option( 'elementor_safe_mode_allowed_plugins' );
} );
add_filter( 'pre_option_stylesheet', function () {
return 'elementor-safe';
} );
add_filter( 'pre_option_template', function () {
return 'elementor-safe';
} );
add_action( 'elementor/init', function () {
do_action( 'elementor/safe_mode/init' );
} );
}
/**
* Plugin row meta.
*
* Adds row meta links to the plugin list table
*
* Fired by `plugin_row_meta` filter.
*
* @access public
*
* @param array $plugin_meta An array of the plugin's metadata, including
* the version, author, author URI, and plugin URI.
* @param string $plugin_file Path to the plugin file, relative to the plugins
* directory.
*
* @return array An array of plugin row meta links.
*/
public function plugin_row_meta( $plugin_meta, $plugin_file, $plugin_data, $status ) {
if ( basename( __FILE__ ) === $plugin_file ) {
$row_meta = [
'docs' => '<a href="https://go.elementor.com/safe-mode/" aria-label="' . esc_attr( esc_html__( 'Learn More', 'elementor' ) ) . '" target="_blank">' . esc_html__( 'Learn More', 'elementor' ) . '</a>',
];
$plugin_meta = array_merge( $plugin_meta, $row_meta );
}
return $plugin_meta;
}
public function __construct() {
add_filter( 'plugin_row_meta', [ $this, 'plugin_row_meta' ], 10, 4 );
$enabled_type = $this->is_enabled();
if ( ! $enabled_type || ! $this->is_valid_token() ) {
return;
}
if ( ! $this->is_requested() && 'global' !== $enabled_type ) {
return;
}
if ( ! $this->is_editor() && ! $this->is_editor_preview() && ! $this->is_editor_ajax() ) {
return;
}
$this->add_hooks();
}
}
new Safe_Mode();