Wordpress get current time error on functions.php - wordpress

I want to get the current time of wordpress, but I got errors, how to fix it? is there another way to get the current time of the wordpress?, I want the time that wordpress using with format (+GMT) and what the user choose, not the server time.
This is my code
<?php
require_once( '/wp-includes/functions.php' );
$format = get_option('date_format') . ' ' . get_option('time_format');
print date_i18n($format, current_time('timestamp'));
?>
These are the errors
Notice: Use of undefined constant ABSPATH - assumed 'ABSPATH' in C:\xampp1\htdocs\wp\wp-includes\functions.php on line 8
Notice: Use of undefined constant WPINC - assumed 'WPINC' in C:\xampp1\htdocs\wp\wp-includes\functions.php on line 8
Warning: require(ABSPATHWPINC/option.php): failed to open stream: No such file or directory in C:\xampp1\htdocs\wp\wp-includes\functions.php on line 8
Fatal error: require(): Failed opening required 'ABSPATHWPINC/option.php' (include_path='.;C:\xampp1\php\PEAR') in C:\xampp1\htdocs\wp\wp-includes\functions.php on line 8

You don't need to include require_once( '/wp-includes/functions.php' );. Directly use the function it will return GMT time like below
<?php echo current_time( 'mysql', 1 ); ?>
For more Please refer this link http://codex.wordpress.org/Function_Reference/current_time

Related

Fatal error within Woocommerce "wc-template-functions.php" file

I have tried to edit wc-template-functions.php in my store and did something wrong.
Now I am getting Fatal Error on 281 line.
Fatal error: Uncaught Error: Class 'Constants' not found in /home/kidsandm/oliverthedog/wp-content/plugins/woocommerce/includes/wc-template-functions.php:282 Stack trace: #0 /home/kidsandm/oliverthedog/wp-includes/class-wp-hook.php(292): wc_generator_tag('<meta name="gen...', 'xhtml') #1 /home/kidsandm/oliverthedog/wp-includes/plugin.php(212): WP_Hook->apply_filters('<meta name="gen...', Array) #2 /home/kidsandm/oliverthedog/wp-includes/general-template.php(4728): apply_filters('get_the_generat...', '<meta name="gen...', 'xhtml') #3 /home/kidsandm/oliverthedog/wp-includes/general-template.php(4650): get_the_generator('xhtml') #4 /home/kidsandm/oliverthedog/wp-includes/general-template.php(4627): the_generator('xhtml') #5 /home/kidsandm/oliverthedog/wp-includes/class-wp-hook.php(292): wp_generator('') #6 /home/kidsandm/oliverthedog/wp-includes/class-wp-hook.php(316): WP_Hook->apply_filters(NULL, Array) #7 /home/kidsandm/oliverthedog/wp-includes/plugin.php(484): WP_Hook->do_action(Array) #8 /home/kidsandm/oliverthedog/wp-includes/gen in /home/kidsandm/oliverthedog/wp-content/plugins/woocommerce/includes/wc-template-functions.php on line 282
Before that I also had warning at the top that said:
Warning: The use statement with non-compound name 'AutomatticJetpackConstants' has no effect in /home/kidsandm/hondamarine/wp-content/plugins/woocommerce/includes/wc-template-functions.php on line 11
but I have hide that line thinking it might help.
What I have change in file?
Additional information.
I was thinking it will change the name of it on front-end as well.
// Additional information tab - shows attributes.
if ( $product && ( $product->has_attributes() || apply_filters( 'wc_product_enable_dimensions_display', $product->has_weight() || $product->has_dimensions() ) ) ) {
$tabs['additional_information'] = array(
'title' => __( 'Additional information', 'woocommerce' ),
'priority' => 20,
'callback' => 'woocommerce_product_additional_information_tab',
);
}
Line 1798.
I have tried to find a code only to replace it, and I found one but did not help.
Now, that code might not be original because I could not find it on GitHub.
Thanks a lot!
It just happened to me too, I tried to edit the code for the same reason, I searched a lot about this problem and I solved it when I downloaded the plugin in zip form and manually upload it and install it, now its working fine for me and all data still in place (categories, products, etc.)!
I had the following 2 errors:
Fatal Error: Uncaught error: Class 'Constants' not found in /Users/anastasiades/Local Sites/pisinaspa/app/public/wp-content/plugins/woocommerce/includes/wc-template-functions.php on line 282
Error: Class 'Constants' not found in /Users/anastasiades/Local Sites/pisinaspa/app/public/wp-content/plugins/woocommerce/includes/wc-template-functions.php on line 282
Steps:
1. Backup data in woocommerce
2. Download plugin here
3. On WordPress go to Plugins >> Add new >> Upload plugin
4. Choose Reinstall >> Install now
5. "Replace current with uploaded"
I recommend a good backup of the products and other data before doing this.
Peace!

Warning: preg_replace(): Unknown modifier 'j' in

I use the Amazon AI plugin that runs amazon, Polly.
All was Ok but know I'm getting an error.
I open the code in Cpanel.
$text = preg_replace('/<' . $value . '>(\s*?)(.?)(\s?)</' . $value . '>/', '', $text);
What should I do? with this error:
Warning: preg_replace(): Unknown modifier 'j' in /amazon-polly/admin/AmazonAI-Common.php on line 1313
Can you use preg_quote instead of preg_replace?

Why do I encounter Fatal error in publishing a Responsive Pricing Table?

Once I hit publish in Add New pricing table I encounter this error:
Fatal error: Call to undefined function sanitize_hex_color() in /var/domains/main/wp-content/plugins/dk-pricr-responsive-pricing-table/inc/rpt-save-metaboxes.php on line 69
in WordPress version 4.6, this function has been moved to the file wp-includes/formatting.php, first include this file, and then call the function :
if ( ! function_exists( 'sanitize_hex_color' ) ) {
include ABSPATH . 'wp-includes/formatting.php';
}

Wordpress : Genesis-Legacy Theme error

I am getting this error message on some of my pages within worrdpress dashboard.
Google Analytics Stats
Warning: array_merge(): Argument #1 is not an array in
/home/c5280den/public_html/wp-content/plugins/google-analyticator/google-api-php-client/src/Google_Client.php
on line 40
Fatal error: Class name must be a valid object or a string in
/home/c5280den/public_html/wp-content/plugins/google-analyticator/google-api-php-client/src/Google_Client.php
on line 104
Any help is most appreciated!!
Update your plugin bro.. If updated already, try this.
FILE - google-analyticator > google-api-php-client > src > Google_Client.php
OLD CODE (starting at Line 35)
require_once "config.php";
// If a local configuration file is found, merge it's values with the default configuration
if (file_exists(dirname(__FILE__) . '/local_config.php')) {
$defaultConfig = $apiConfig;
require_once (dirname(__FILE__) . '/local_config.php');
$apiConfig = array_merge($defaultConfig, $apiConfig);
NEW CODE (starting at Line 35)
require_once (dirname(__FILE__) . "/config.php");
// If a local configuration file is found, merge it's values with the default configuration
if (file_exists(dirname(__FILE__) . '/local_config.php')) {
$defaultConfig = $apiConfig;
require_once (dirname(__FILE__) . '/local_config.php');
$apiConfig = array_merge($defaultConfig, $apiConfig);
Adding to line 35...
require_once (dirname(__FILE__) . "/config.php");
in place of...
require_once "config.php";
seems to have fixed the problem.
Get it from here https://wordpress.org/support/topic/recent-update-throws-error-in-settings-page

Error by read the file size PHP

I want to get the file size of an attachment of my wordpress post.
But when I run the site, I get this error ...
Can anyone help me?
"Warning: filesize(): stat failed for http://XXX.de/webdev/wp-content/uploads/2013/03/example.zip in C:\Users\XXX\Desktop\XAMPP\htdocs\webdev\wp-content\themes\web dev-theme\modul-page.php on line 27"
<?php
$a = filesize($img['url']);
echo$a;
?>
Thanks!
First check and see if the files/dirs are read/writeable.
I would do this inside of a file exist just for best practices. It is hard to determine what is wrong because you have not specified what line 27 is.
if ( file_exists($img['url']) ) {
$the_file_size = filesize($img['url']);
if ( $the_file_size >= 0 ) {
echo $the_file_size . ' bytes';
} else {
echo "File size could not be determined";
}
}

Resources