wordpress-plugin

wordpress Fatal error: Out of memory

眉间皱痕 提交于 2019-12-02 11:16:22
问题 I have set php memory limit from whm to 256M from WHM > PHP Configuration Editor. Even so, my wordpress website and admin is showing me an error like below. Fatal error: Out of memory (allocated 36175872) (tried to allocate 30720 bytes) in /home/XXXX/public_html/wp-includes/class-simplepie.php on line 14272 Fatal error: Out of memory (allocated 35127296) (tried to allocate 1966080 bytes) in /home/XXXX/public_html/wp-includes/class-simplepie.php on line 5427 I also tried to add following line

Insert into wordpress database - Call to a member function insert()

此生再无相见时 提交于 2019-12-02 09:58:27
Im having an issue with inserting data into the wordpress database through my plugin. My plugin uses a shortcode to display a form from which some calculations are made and then that information is the then supposed to be inserted into the database but I end up getting this message. I can't seem to get it to work?.. Any help would be appreciated greatly. PLUGIN CODE used for the insert: include_once($_SERVER['DOCUMENT_ROOT'].'/wp-config.php' ); $wpdb->insert( 'wp_wine_bookings', array( 'name' => $_POST['name'], 'last_name' => $_POST['lname'], 'phone_number' => $_POST['phone_num'], 'email' => $

Woocommerce Mini Cart Widget product price override

冷暖自知 提交于 2019-12-02 09:30:12
问题 is it possible to change product price in Woocommerce Mini Cart Widget? I've overrided price in cart using tips from WooCommerce: Add product to cart with price override? but it only works for cart page. Prices in widget are not changed. 回答1: This is how I set price to 0 for free products: function set_free_items_price( $price, $cart_item, $cart_item_key ) { $returned_item_price = $cart_item['data']->get_price(); if (isset($cart_item['free_item']['value']) && $cart_item['free_item']['value']

wordpress plugin: query post-ID in plugin?

ε祈祈猫儿з 提交于 2019-12-02 09:18:10
hey guys, maybe some of you have experience with programming wordpress plugins. I have a probably rather simpel question, but i couldn't find anything on the web. <?php /* Plugin Name: test */ function test($content) { echo $post_id; return $content; } add_filter('the_content', 'test'); ?> I have a simpel plugin that should echo out the unique ID of every post in it's content. So on my frontpage with 10 posts every post should have it's ID echoed out. Any idea how to achieve that? thank you! My guess is Use global keyword to access post id in function And also my guess is return and echo both

Create a Flash frontend for WordPress?

大城市里の小女人 提交于 2019-12-02 07:34:28
My buddy wants to create a WordPress blog, but because he's picky about the design (specifically the fonts), he wants to use Flash for the frontend -- display, content creation, user interface, etc. He's looking for a plug-in that will take the user input from the Flash interface and convert it into the appropriate PHP for WordPress. I've never used Flash, so I didn't know what to tell him, other than that this sounds nuts. Is there a better answer than this? Flash can store and retreive information via HTTP easily enough, and I think Wordpress makes most things available via an XML-RPC

Using wp_mail() instead of mail() in Wordpress does not work

前提是你 提交于 2019-12-02 06:05:15
Since PHP mail has been disabled on my server it has stopped a theme integrated contact form from working. The theme is called Boldy and it has its own sendmail.php file which uses mail() instead of wp_mail() . Changing mail() to wp_mail() does not work, but I'm not sure why? <?php if (isset($_POST['submit'])) { error_reporting(E_NOTICE); function valid_email($str) { return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE; } if ($_POST['name'] != '' && $_POST['email'] != '' && valid_email($_POST['email']) == TRUE && strlen($_POST[

How to round up the price in wordpress to the nearest value?

那年仲夏 提交于 2019-12-02 04:31:57
问题 I am using following function to round up the price in wordpress.. add_filter( 'woocommerce_get_price_excluding_tax', 'round_price_product', 10, 1 ); add_filter( 'woocommerce_get_price_including_tax', 'round_price_product', 10, 1 ); add_filter( 'woocommerce_tax_round', 'round_price_product', 10, 1); add_filter( 'woocommerce_get_price', 'round_price_product', 10, 1); function round_price_product( $price ){ // Return rounded price return ceil( $price ); } The above function round up the prices

WordPress global $post variable is empty

梦想的初衷 提交于 2019-12-02 04:16:44
I'm working on a wordpress plugin(managing background image), when I try to use global $post; print_r($post); the object is empty. Probably there is some required data (I dont know what.) Please help me if you know. The WordPress global variable $post contains the data of the current Post within the The Loop . This means that WordPress will assign a value to this variable in each loop iteration. Consecuently, if you're trying to access $post from anywhere in your code outside the WP loop, it will be of course empty... 来源: https://stackoverflow.com/questions/22745077/wordpress-global-post

How can I add meta data to the head section of the page from a wordpress plugin?

半腔热情 提交于 2019-12-02 04:14:05
问题 I am writing a wordpress plugin and need to add some meta tags to the head section of the page from within my plugin. Does anyone know how I would do this? Thanks 回答1: Yes you can add an action hook to wp_head like this: add_action('wp_head', myCallbackToAddMeta); function myCallbacktoAddMeta(){ echo "\t<meta name='keywords' content='$contents' />\n"; } 来源: https://stackoverflow.com/questions/5805888/how-can-i-add-meta-data-to-the-head-section-of-the-page-from-a-wordpress-plugin

Woocommerce Mini Cart Widget product price override

為{幸葍}努か 提交于 2019-12-02 04:13:10
is it possible to change product price in Woocommerce Mini Cart Widget? I've overrided price in cart using tips from WooCommerce: Add product to cart with price override? but it only works for cart page. Prices in widget are not changed. This is how I set price to 0 for free products: function set_free_items_price( $price, $cart_item, $cart_item_key ) { $returned_item_price = $cart_item['data']->get_price(); if (isset($cart_item['free_item']['value']) && $cart_item['free_item']['value'] == true) { $returned_item_price = 0; } return get_woocommerce_currency_symbol() . $returned_item_price; } I