Woocommerce issue - wordpress

so due to a business change I have un-installed the woo commerce plugin and than re-installed it.
now on the all the products I create it throws me this error( becaus it is public on the webpage no matter what I do)
Warning: sprintf(): Too few arguments in /home/xxxx/public_html/wp/wp-includes/functions.php on line 3829
Notice: in /home/xxxxxx/public_html/wp/wp-includes/functions.php on line 3829
Notice: ID was called incorrectly. Product properties should not be accessed directly. Please see Debugging in WordPress for more information. (This message was added in version 3.0.) in /home/xxxx/public_html/wp/wp-includes/functions.php on line 4137
the code at line 3289
* Filters whether to trigger an error for deprecated functions.
*
* #since 2.5.0
*
* #param bool $trigger Whether to trigger the error for deprecated
functions. Default true.
*/
if ( WP_DEBUG && apply_filters( 'deprecated_function_trigger_error', true ) ) {
if ( function_exists( '__' ) ) {
if ( ! is_null( $replacement ) ) {
/* translators: 1: PHP function name, 2: version number, 3: alternative function name */
trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $function, $version, $replacement ) );
} else {
/* translators: 1: PHP function name, 2: version number */
trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version ) );
}
} else {
if ( ! is_null( $replacement ) ) {
trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $function, $version, $replacement ) );
} else {
trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $function, $version ) );
}
and than at page 4137
#param bool $trigger Whether to trigger the error for _doing_it_wrong() calls. Default true.
*/
if ( WP_DEBUG && apply_filters( 'doing_it_wrong_trigger_error', true ) ) {
if ( function_exists( '__' ) ) {
if ( is_null( $version ) ) {
$version = '';
} else {
/* translators: %s: version number */
$version = sprintf( __( '(This message was added in version %s.)' ), $version );
}
/* translators: %s: Codex URL */
$message .= ' ' . sprintf( __( 'Please see Debugging in WordPress for more information.' ),
__( 'https://codex.wordpress.org/Debugging_in_WordPress' )
);
/* translators: Developer debugging message. 1: PHP function name, 2: Explanatory message, 3: Version information message */
trigger_error( sprintf( __( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s' ), $function, $message, $version ) );
} else {
if ( is_null( $version ) ) {
$version = '';
} else {
$version = sprintf( '(This message was added in version %s.)', $version );
}
$message .= sprintf( ' Please see Debugging in WordPress for more information.',
'https://codex.wordpress.org/Debugging_in_WordPress'
);
trigger_error( sprintf( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s', $function, $message, $version ) );
}
could somebody hint a possible resolution?

Related

File doesn't exist! in wordpress function.php file while creating new post or page

function wp_json_file_decode( $filename, $options = array() ) {
$result = null;
$filename = wp_normalize_path( realpath( $filename ) );
if ( ! file_exists( $filename ) ) {
trigger_error(
sprintf(
/* translators: %s: Path to the JSON file. */
__( "File %s doesn't exist!" ),
$filename
)
);
return $result;
}
$options = wp_parse_args( $options, array( 'associative' => false ) );
$decoded_file = json_decode( file_get_contents( $filename ), $options['associative'] );
if ( JSON_ERROR_NONE !== json_last_error() ) {
trigger_error(
sprintf(
/* translators: 1: Path to the JSON file, 2: Error message. */
__( 'Error when decoding a JSON file at path %1$s: %2$s' ),
$filename,
json_last_error_msg()
)
);
return $result;
}
return $decoded_file;
}
i have been working on wordpress website,
cant able to create new post
cant able to create new page
is there any plugin errors

How to change Wordpress Password Reset Email?

I want to change the default Password Reset Email in Wordpress 5.2.2
I have tried the following code but it is not working.
add_filter( 'retrieve_password_message', 'my_retrieve_password_message', 10, 4 );
function my_retrieve_password_message( $message, $key, $user_login, $user_data ) {
// Start with the default content.
$site_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
$message = __( '(UPDATED)Someone has requested a password reset for the following account:' ) . "\r\n\r\n";
/* translators: %s: site name */
$message .= sprintf( __( 'Site Name: %s' ), $site_name ) . "\r\n\r\n";
/* translators: %s: user login */
$message .= sprintf( __( 'Username: %s' ), $user_login ) . "\r\n\r\n";
$message .= __( 'If this was a mistake, just ignore this email and nothing will happen.' ) . "\r\n\r\n";
$message .= __( 'To reset your password, visit the following address:' ) . "\r\n\r\n";
$message .= '<' . network_site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user_login ), 'login' ) . ">\r\n";
// Return the filtered message.
return $message;
}
Any help would be appreciated.
This answer here is working well for me: https://wordpress.stackexchange.com/a/262425
And here is how you can change the email it sends from and the subject.
// Function to change default wordpress#domain.com email address
function wp_sender_email( $original_email_address ) {
return 'YOUR_EMAIL_HERE';
}
// Function to change sender name
function wp_sender_name( $original_email_from ) {
return 'YOUR_SUBJECT_HERE';
}
// Add our functions to WordPress filters
add_filter( 'wp_mail_from', 'wp_sender_email' );
add_filter( 'wp_mail_from_name', 'wp_sender_name' );

custom error message instead of FATAL ERROR in Wordpress plugin activation if WooCommerce is not acive

I am trying to give a graceful custom message upon activation of the plugin, if Woocommerce is not activated.
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
The above express is to check whether Woocommerce is active and if it returns false, I do not want the plugin to be activated and wants to throw a custom error. I have tried to stop execution with die() and trigger_error. In these cases, it shows a FATAL ERROR.
What I usually do is throw and admin notice if WooCommerce isn't available. And then just stop the running of your plugin.
if ( ! in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ){
add_action( 'admin_notices', 'so_32551934_woocommerce_warning' );
return; // STOP THE WHOLE PLUGIN
}
function so_32551934_woocommerce_warning(){ ?>
<div class="error">
<p><?php _e( 'Whoa, you\'re gonna need WooCommerce to run my fancy plugin!', 'my-text-domain' ); ?></p>
</div>
<?php
}
// The rest of your plugin follows here
Any code that you put here at the end will be run as long as WooCommerce is active. Note, I didn't test this so be careful of typos.
Have a look at deactivate_plugins function . Try this:
class MyPlugin {
public function __construct() {
register_activation_hook( __FILE__, array( $this , 'activate' ) );
}
public function activate() {
// Check if Woo is active
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
// Woo is active.
} else {
deactivate_plugins( plugin_basename( __FILE__ ) );
wp_die( __( 'Please activate WooCommerce.', 'my-plugin' ), 'Plugin dependency check', array( 'back_link' => true ) );
}
// Do activate Stuff now.
}
}
new MyPlugin();
Here my solution:
class FT_AdminNotice {
/**
* Register the activation hook
*/
public function __construct() {
register_activation_hook( __FILE__, array( $this, 'ft_install' ) );
}
/**
* Deactivate the plugin and display a notice if the dependent plugin is not active.
*/
public function ft_install() {
if ( ! class_exists( 'WooCommerce' ) )
{
$this->ft_deactivate_plugin();
wp_die( sprintf(__( 'This plugin requires Woocommerce to be installed and activated.', 'domain-text' ) ) );
}
}
/**
* Function to deactivate the plugin
*/
protected function ft_deactivate_plugin() {
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
deactivate_plugins( plugin_basename( __FILE__ ) );
if ( isset( $_GET['activate'] ) ) {
unset( $_GET['activate'] );
}
}
}
new FT_AdminNotice();
This way show message and you can enrich it like explain here and stop execution too.

wp_register_script error on WP migration

I'm trying to migrate a wordpress site, and i'm receiving this error when debugging on the new server:
Notice: wp_register_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. Please see Debugging in WordPress for more information. (This message was added in version 3.3.) in /home/binaryop/public_html/wp-includes/functions.php on line 3049
Line 3049 looks like this (the one beginning with trigger_error)
function _doing_it_wrong( $function, $message, $version ) {
do_action( 'doing_it_wrong_run', $function, $message, $version );
// Allow plugin to filter the output error trigger
if ( WP_DEBUG && apply_filters( 'doing_it_wrong_trigger_error', true ) ) {
if ( function_exists( '__' ) ) {
$version = is_null( $version ) ? '' : sprintf( __( '(This message was added in version %s.)' ), $version );
$message .= ' ' . __( 'Please see Debugging in WordPress for more information.' );
trigger_error( sprintf( __( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s' ), $function, $message, $version ) );
} else {
$version = is_null( $version ) ? '' : sprintf( '(This message was added in version %s.)', $version );
$message .= ' Please see Debugging in WordPress for more information.';
trigger_error( sprintf( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s', $function, $message, $version ) );
}
}
}
However, I can't see any use of wp_register_script in the functions.php, so i'm confused by what's causing this. Any ideas?
The file / line it's telling you to look in is incorrect.
I'd start by disabling all your plugins and seeing if the error persists.
More likely however is the issue being inside a theme file. If disabling all the plugins doesn't resolve the error switch your theme to test.
You're seeing this issue on the new host because of a difference in error reporting. The issue will have been present on the old host but not shown to you.
Anyway let me know the results of the tests above and I'll adjust my answer accordingly.

notifications for buddypress Like plugin

I'm using the Buddypress like plugin which adds the feature to like status updates. Now when a user likes something it doesn't sent a status notification like other buddypress components do. I tried to edit the plugin's code to add this functionality and added the following code to bp-like.php, but still didn't work:
/******************************************************
/* Notification
*****************************************************/
function bp_like_setup_globals() {
global $bp, $current_blog;
$bp->bp_like->id = 'bp_like_notifier';
$bp->bp_like->slug = 'BP_LIKE_SLUG';
$bp->bp_like->notification_callback = 'like_format_notifications';
$bp->active_components[$bp->bp_like->slug] = $bp->bp_like->id;
do_action( 'bp_like_setup_globals' );
}
add_action( 'bp_setup_globals', 'bp_like_setup_globals' );
function like_format_notifications( $action, $item_id, $secondary_item_id, $total_items ) {
global $bp;
$link=like_notifier_activity_get_permalink( $item_id );
if( 'activity_like' == $action ) {
if ( (int)$total_items > 1 )
return apply_filters( 'log_multiple_verifications_notification', '' . sprintf( __('You have %d new likes', 'bp-like' ), (int)$total_items ) . '', $total_items );
else
return apply_filters( 'log_single_verification_notification', '' . sprintf( __('You have %d new like', 'bp-like' ), (int)$total_items ) . '', $total_items );
}
do_action( 'like_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
return false;
}
function like_remove_screen_notifications() {
global $bp;
if($has_access)//if user can view this activity, remove notification(just a safeguard for hidden activity)
bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->bp_like->id, 'new_like' );
}
add_action( 'bp_activity_screen_single_activity_permalink', 'like_remove_screen_notifications' );
//get the thread permalink for activity
function like_notifier_activity_get_permalink( $item_id, $activity_obj = false ) {
global $bp;
if ( !$activity_obj )
$activity_obj = new BP_Activity_Activity( $item_id );
if ( 'activity_comment' == $activity_obj->type )
$link = $bp->root_domain . '/' . BP_ACTIVITY_SLUG . '/p/' . $activity_obj->item_id . '/';
else
$link = $bp->root_domain . '/' . BP_ACTIVITY_SLUG . '/p/' . $activity_obj->id . '/';
return apply_filters( 'like_notifier_activity_get_permalink', $link );
}
and inside bp_like_add_user_like() function I put this after $liked_count = count( $users_who_like ):
bp_core_add_notification( $item_id, $user_id, $bp->bp_like->id, 'activity_like' );
so far this didn't work.. any idea what I'm missing here?
thanks

Resources