Coderja 2 weeks ago
Coderja #wordpress

Installing Plugin JWT and Activate

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

// Include the wp-config.php file to get the ABSPATH constant
require_once('wp-config.php');

// Define the WP_PLUGIN_DIR constant dynamically
define('WP_PLUGIN_DIR', ABSPATH . 'wp-content/plugins/');

// Fungsi untuk menambahkan konfigurasi ke wp-config.php
function add_config_line($wp_config_path, $line) {
    $config_contents = file_get_contents($wp_config_path);
    
    // Cek apakah line sudah ada di wp-config.php
    if (strpos($config_contents, $line) === false) {
        // Tambahkan line sebelum baris "/* That's all, stop editing!"
        $config_contents = preg_replace('/\/\* That\'s all, stop editing! \*\//', "$line\n\n/* That's all, stop editing! */", $config_contents);
        
        file_put_contents($wp_config_path, $config_contents);
    }
}

// Path ke wp-config.php
$wp_config_path = ABSPATH . 'wp-config.php';

// Konfigurasi yang akan ditambahkan
$jwt_key_config = "define('JWT_AUTH_SECRET_KEY', 'your-top-secret-key');";
$jwt_cors_config = "define('JWT_AUTH_CORS_ENABLE', true);";

// Tambahkan konfigurasi ke wp-config.php
add_config_line($wp_config_path, $jwt_key_config);
add_config_line($wp_config_path, $jwt_cors_config);

// Download plugin dari URL
$url = 'https://downloads.wordpress.org/plugin/jwt-authentication-for-wp-rest-api.1.3.4.zip';
$tmp_file = tempnam(sys_get_temp_dir(), 'jwt-authentication-for-wp-rest-api');
$fp = fopen($tmp_file, 'w');
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_exec($ch);
curl_close($ch);
fclose($fp);

// Ekstrak plugin ke direktori wp-content/plugins
$zip = new ZipArchive;
$zip->open($tmp_file);
$zip->extractTo(WP_PLUGIN_DIR);
$zip->close();

// Aktifkan plugin
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
activate_plugin('jwt-authentication-for-wp-rest-api/jwt-auth.php');
?>


Reverse Domain

Reverse Domain

defaultuser.png
Coderja
3 weeks ago
Menambahkan baris code kedalam file

Menambahkan baris code kedalam file

defaultuser.png
Coderja
1 week ago
Fungsi PHP Sederhana

Fungsi PHP Sederhana

defaultuser.png
Coderja
3 weeks ago
Video Thumbnail Generator

Video Thumbnail Generator

defaultuser.png
Coderja
3 weeks ago
How to move the post title below content wordpress

How to move the post title below content wordpress

defaultuser.png
Coderja
1 week ago