Wordpress Jetpack Plugin simple_payments issue - wordpress

I just updated the jetpack wordpress plugin, and this error happened:
Fatal Error (E_ERROR): Call to undefined method Jetpack_Simple_Payments::is_enabled_jetpack_simple_payments() occurred in wp-content/plugins/jetpack/modules/widgets/simple-payments.php on line 480 please make sure that your website is accessible
Does any one has any approach about a solution? Thanks,

for the time being you can add the missing method is_enabled_jetpack_simple_payments in the file:
jetpack/modules/simple-payments/simple-payments.php
function is_enabled_jetpack_simple_payments() {
/**
* Can be used by plugin authors to disable the conflicting output of Simple Payments.
*
* #since 6.3.0
*
* #param bool True if Simple Payments should be disabled, false otherwise.
*/
if ( apply_filters( 'jetpack_disable_simple_payments', false ) ) {
return false;
}
// For WPCOM sites
if ( defined( 'IS_WPCOM' ) && IS_WPCOM && function_exists( 'has_blog_sticker' ) ) {
$site_id = $this->get_blog_id();
return has_blog_sticker( 'premium-plan', $site_id ) || has_blog_sticker( 'business-plan', $site_id );
}
// For all Jetpack sites
return Jetpack::is_active() && Jetpack::active_plan_supports( 'simple-payments');
}

Related

attempt to read property on null in document.php line 250

attempt to read property on null in document.php line 250
/**
* #since 2.0.0
* #access public
*/
public function get_main_id() {
if ( ! $this->main_id ) {
$post_id = $this->post->ID;
I have the same error. In my case this ocurr after migration of site to other server with All-in-One WP Migration plugin.
The file with problem is: C:\xampp\apps\wordpress\htdocs\wp-content\plugins\elementor\core\base\document.php

Wordpress activate_plugin() can run and return "The plugin does not have a valid header."

hello i tried to build plugin that can install and activate other plugins. the plugins is successfully extracted to "wp-content/plugins" folder but there error when activate_plugin() function running, it return "The plugin does not have a valid header.". Did i do it wrong?
this my plugin script:
<?php
define( 'WP_ADMIN', TRUE );
define( 'WP_NETWORK_ADMIN', TRUE );
define( 'WP_USER_ADMIN', TRUE );
require_once('../../../wp-load.php');
require_once(ABSPATH.'wp-admin/includes/admin.php');
require_once(ABSPATH.'wp-admin/includes/file.php');
require_once(ABSPATH.'wp-admin/includes/plugin.php');
try {
$post = $_POST;
// file_put_contents('logs.txt', json_encode($post));die;
foreach($post['plugins'] as $key => $value){
if($value['is_external_link'] == 0){
$file_url = $post['url_download']."/{$value['id']}";
}else{
$file_url = $value['external_link'];
}
$tmp_file = download_url($file_url);
copy($tmp_file, $value['file_name']);
unlink($tmpfile);
// extract plugin to plugins folder
$zip = new ZipArchive;
$zip->open($value['file_name']);
$zip->extractTo(ABSPATH.'wp-content/plugins/');
$zip->close();
// remove zip file
unlink($value['file_name']);
// activate plugin
$res = activate_plugin(ABSPATH.'wp-content/plugins/'.$value['folder_name']);
file_put_contents("logs$key.txt", $res->get_error_messages());
}
} catch (\Throwable $th) {
file_put_contents('log.txt', $th);
}
Oh the problem already clear, i just need to include the core file script, so instead of "wp-content/plugins/plugin-name/", change to "wp-content/plugins/plugin-name/plugin-name.php".
Oviously, your code missing plugin header right after the open <?php tag.
It's some thing like this:
/**
* Plugin Name: My Basics Plugin
* Plugin URI: https://example.com/plugins/the-basics/
* Description: Handle the basics with this plugin.
* Version: 1.10.3
* Requires at least: 5.2
* Requires PHP: 7.2
* Author: John Smith
* Author URI: https://author.example.com/
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: my-basics-plugin
* Domain Path: /languages
*/
Or atleat you need the Plugin Name to activate it!!

Laravel 5 ovewrite helper function __() because used in wordpress

I have read several post on stackoverflow but didn't help, so i hope somebody can give the good answer.
I am using Laravel with wordpress. Now there is an error. Is it possible to rename or other method to change this?
Error:
Fatal error: Cannot redeclare __() (previously declared in C:app\laravel\vendor\laravel\framework\src\Illuminate\Foundation\helpers.php:821)
Laravel 5.4 added a helper function called __()
This function has the same name as WordPress's.
Just rename Laravel's __ to ___ and run "composer update".
You can find the file in:
[project folder]\vendor\laravel\framework\src\Illuminate\Foundation\helpers.php
The problematic function is in line 947.
Don't forget to pay attention to line 938 as well.
I had this exact same issue. Couldn't do it with Bas's solution, though. Hope this helps someone.
NOTE: You shoud never change files in the Vendor folder, as they would need to be maintained. I do not recommend this solution unless you understand the consequences. Still, it gets the job done.
In de file wp-blog-header.php load before wp-load.php the l110n.php
if ( !isset($wp_did_header) ) {
$wp_did_header = true;
// Load the WordPress library.
require_once( dirname(__FILE__).'/wp-includes/l10n.php' );
require_once( dirname(__FILE__) . '/wp-load.php' );
// Set up the WordPress query.
wp();
// Load the theme template.
require_once( ABSPATH . WPINC . '/template-loader.php' );
}
And make a own helpers file in your LARAVEL project with this function with ownname:
if (! function_exists('ownname')) {
/**
* Translate the given message.
*
* #param string $key
* #param array $replace
* #param string $locale
* #return \Illuminate\Contracts\Translation\Translator|string
*/
function ownname($key = null, $replace = [], $locale = null)
{
return app('translator')->getFromJson($key, $replace, $locale);
}
}

Customize upload folder for sites

I´ve just installed a wordpress multisite installation (version 4.2.1) with mapped domains.
For each site the url for an uploaded image which is shown in the browser is http://URL/wp-content/uploads/sites/SITENUMBER/DATE/... and the folder is /path/to/wordpress/wp-content/uploads/sites/SITENUMBER/DATE/....
But I want to use the local path /path/to/wordpress/wp-content/uploads/sites/SITENUMBER/... and want to see in the browser http://URL/wp-content/uploads/DATE/... (like in a single wordpress site).
I´ve read a much about that and I think I know that the option "UPLOAD URL PATH" normally should rewrite this, doesn´t it? But for me it doesn´t work. How could I customize wordpress to fit it?
Update: I´ve found out that in functions.php are define that multisites will get a rewrite of the URL:
// If multisite (and if not the main site in a post-MU network)
if ( is_multisite() && ! ( is_main_network() && is_main_site() && defined( 'MULTISITE' ) ) ) {
if ( ! get_site_option( 'ms_files_rewriting' ) ) {
/*
* If ms-files rewriting is disabled (networks created post-3.5), it is fairly
* straightforward: Append sites/%d if we're not on the main site (for post-MU
* networks). (The extra directory prevents a four-digit ID from conflicting with
* a year-based directory for the main site. But if a MU-era network has disabled
* ms-files rewriting manually, they don't need the extra directory, as they never
* had wp-content/uploads for the main site.)
*/
if ( defined( 'MULTISITE' ) )
$ms_dir = '/sites/' . get_current_blog_id();
else
$ms_dir = '/' . get_current_blog_id();
$dir .= $ms_dir;
$url .= $ms_dir;
...
}}
But I didn´t know how I could change this to get the needed behavior.
Yes you can change your upload directory in WordPress using below function.
add_filter( 'upload_dir', 'upload_dir_filter' );
function upload_dir_filter( $upload ) {
$dir = $_SERVER['DOCUMENT_ROOT'];
$upload_dir = $dir['basedir'] . '/uploads/date';
$upload_url = $dir['baseurl'] . '/uploads/date';
wp_mkdir_p( $upload_dir ); //WordPress will check if the dir exists and can write to it.
$upload['path'] = $upload_dir;
$upload['url'] = $upload_url;
return $upload;
}

Redirect user to regional language site version by knowing the ip of users Drupal 7

We are basically developing a Drupal 7 site with multiple language support.
Users should be redirected to regional translated pages basing on their IP.
I have tried using the following modules, but they didn't help to achieve what I wanted.
Internalization
IP to Locale
How can I redirect users to a specific page basing on their IP?
I have added a module for the same... just adding the code. With little modifications it can be configured for any no of languages and options.
I am using APIs from http://ipinfodb.com/.
ip2locationlite.class.php -> file can be downloaded from this link "http://ipinfodb.com/ip_location_api.php". The file consists of a very simple class, just used for calling webservice provided by http://ipinfodb.com/ and can be avoided by using your own class with file_get_contents.
I used for only chinese.
/** Author : Sunny Jhunjhunwala (sunny.jhunjhunwala#sourcen.com)
* #file - the file basically uses the php api provided by ipinfodb to get user's country
*/
/**
* Implements hook_init().
* Only for the first time checks if user is from china or not, if yes then redirect user to chinese version of the site.
*/
function dw_ip2location_init() {
if (!(array_key_exists('visited', $_COOKIE)) && empty($GLOBALS['user']->uid)) {
// Set the cookie to check if the user is new or existing.
setcookie("visited", 1, time() + (10 * 365 * 24 * 60 * 60));
include_once ('ip2locationlite.class.php');
$ipLite = new ip2location_lite;
$ipLite->setKey('a00740f71ae6ed8db250cb4c3a8ecdac672b5eae4d2a28c06284aa5461d0636d');
// #TODO : remove the below if-else while moving to production.
if (isset($_GET['ip2location'])) {
$locations = $ipLite->getCountry($_GET['ip2location']);
} else {
$locations = $ipLite->getCountry($_SERVER['REMOTE_ADDR']);
}
if (!empty($locations) && is_array($locations)) {
// Checking if the user if from china and redirecting.
if ($locations['countryCode'] == 'CN' || $locations['countryName'] == 'china') {
$path = $_GET['q'];
$translations = i18n_get_path_translations($path);
$language = i18n_language_interface();
if($language->prefix != 'cn' ) {
global $base_url;
if(!drupal_is_front_page() && array_key_exists('zh-hans', $translations)) {
drupal_goto( $base_url . '/cn/' . $translations['zh-hans']['href'], array('absolute' => true));
}
else {
drupal_goto( $base_url . '/cn/', array('absolute' => true));
}
}
}
}
}
}

Resources