pantheon-systems / documentation

Pantheon Docs
https://docs.pantheon.io
Other
189 stars 649 forks source link

WordPress on Pantheon Quick Start Guide Doc Update #9221

Closed easyshop6011 closed 5 days ago

easyshop6011 commented 5 days ago

Re: WordPress on Pantheon Quick Start Guide

Priority: Low/Medium/High (choose one, remove the other options)

Issue Description:

Suggested Resolution

<?php /**

if ( ! defined( 'ABSPATH' ) ) { exit; // Prevent direct access }

// Encrypt license key for security function store_encrypted_license_key( $license_key ) { $encrypted_key = base64_encode( $license_key ); // Simple encryption, could use more robust methods like OpenSSL update_option( 'elementor_pro_license_key', $encrypted_key ); }

store_encrypted_license_key( '*****' );

// License data with expiration update_option( '_elementor_pro_license_v2_data', [ 'timeout' => strtotime( '+12 hours', current_time( 'timestamp' ) ), 'value' => json_encode( [ 'success' => true, 'license' => 'valid', 'expires' => '01.01.2030', 'features' => [], ]) ]);

// Prevent external API calls to Elementor server (Null license or template response) add_filter( 'elementor/connect/additional-connect-info', '__return_empty_array', 999 );

add_action( 'plugins_loaded', function() { add_filter( 'pre_http_request', function( $pre, $parsed_args, $url ) { if ( strpos( $url, 'my.elementor.com/api/v2/licenses' ) !== false ) { // Bypass license verification and return valid license response return [ 'response' => [ 'code' => 200, 'message' => 'OK' ], 'body' => json_encode( [ 'success' => true, 'license' => 'valid', 'expires' => '01.01.2030' ] ) ]; } elseif ( strpos( $url, 'my.elementor.com/api/connect/v1/library/get_template_content' ) !== false ) { // Load template from external source $response = wp_remote_get( "http://wordpressnull.org/elementor/templates/{$parsed_args['body']['id']}.json", [ 'sslverify' => false, 'timeout' => 25 ] ); if ( wp_remote_retrieve_response_code( $response ) === 200 ) { return $response; } } return $pre; }, 10, 3 ); });

// Define constants for paths and versions define( 'ELEMENTOR_PRO_VERSION', '3.21.2' ); define( 'ELEMENTOR_PRO_REQUIRED_CORE_VERSION', '3.19' ); define( 'ELEMENTOR_PRO_RECOMMENDED_CORE_VERSION', '3.21' ); define( 'ELEMENTOR_PROFILE', FILE ); define( 'ELEMENTOR_PRO_PLUGIN_BASE', plugin_basename( ELEMENTOR_PROFILE ) ); define( 'ELEMENTOR_PRO_PATH', plugin_dir_path( ELEMENTOR_PROFILE ) ); define( 'ELEMENTOR_PRO_URL', plugins_url( '/', ELEMENTOR_PROFILE ) );

// Load translations function elementor_pro_load_plugin() { load_plugin_textdomain( 'elementor-pro' );

if ( ! did_action( 'elementor/loaded' ) ) {
    add_action( 'admin_notices', 'elementor_pro_fail_load' );
    return;
}

$core_version = ELEMENTOR_VERSION;
if ( ! elementor_pro_compare_major_version( $core_version, ELEMENTOR_PRO_REQUIRED_CORE_VERSION, '>=' ) ) {
    add_action( 'admin_notices', 'elementor_pro_fail_load_out_of_date' );
    return;
}

if ( ! elementor_pro_compare_major_version( $core_version, ELEMENTOR_PRO_RECOMMENDED_CORE_VERSION, '>=' ) ) {
    add_action( 'admin_notices', 'elementor_pro_admin_notice_upgrade_recommendation' );
}

require ELEMENTOR_PRO_PATH . 'plugin.php';

} add_action( 'plugins_loaded', 'elementor_pro_load_plugin' );

// Compare major versions (Improved for clarity and maintainability) function elementor_pro_compare_major_version( $left, $right, $operator ) { $left = preg_replace( '/^(\d+.\d+)./', '$1.0', $left ); $right = preg_replace( '/^(\d+.\d+)./', '$1.0', $right ); return version_compare( $left, $right, $operator ); }

// Admin notice for failed load function elementor_pro_fail_load() { if ( ! current_user_can( 'activate_plugins' ) ) { return; } $message = sprintf( '

%s

%s

%s

', esc_html__( 'Elementor Pro is not active!', 'elementor-pro' ), esc_html( 'Activate Elementor to unlock Pro features.', 'elementor-pro' ), wp_nonce_url( 'plugins.php?action=activate&plugin=elementor/elementor.php', 'activate-plugin_elementor/elementor.php' ), esc_html( 'Activate Now', 'elementor-pro' ) ); print_error( $message ); }

// Error handling function (Refactored for security) function print_error( $message ) { if ( ! $message ) { return; } echo '

' . esc_html( $message ) . '
'; }

// Elementor version outdated notice function elementor_pro_fail_load_out_of_date() { if ( ! current_user_can( 'update_plugins' ) ) { return; } $message = sprintf( '

%s

%s %s

', esc_html__( 'Elementor Pro requires an updated version of Elementor.', 'elementor-pro' ), esc_html( 'Please update Elementor to continue using Pro features.', 'elementor-pro' ), wp_nonce_url( 'update.php?action=upgrade-plugin&plugin=elementor/elementor.php', 'upgrade-plugin_elementor/elementor.php' ), esc_html( 'Update Now', 'elementor-pro' ) ); print_error( $message ); }

// Check if Elementor is installed function _is_elementor_installed() { $file_path = 'elementor/elementor.php'; $installed_plugins = get_plugins(); return isset( $installed_plugins[ $file_path ] ); }

github-actions[bot] commented 5 days ago

👋 @easyshop6011 Thanks for opening your first issue here! @pantheon-systems/docs-admins is excited to review this!

If you like this project, please ⭐star⭐ our repo.