w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Wordpress/Wishlist Member if foreach else loop
$pageposts = $wpdb->get_results($querystr, OBJECT); $counter = 0; // setup a counter with initial value = 0 if ($pageposts) { global $post; foreach ($pageposts as $post) { setup_postdata($post); $postDate = strtotime($post->post_date); $todaysDate = strtotime(now); if ($postDate > $todaysDate) { echo '<li>'; echo the_title(); echo '</li>'; $counter++; // increment of $counter (+1) } } } if($counter == 0) { // if counter was not incremented, you know that there were no post echo 'no posts!'; }

Categories : PHP

Ajax return issue in a WordPress plugin
Too many issues with your code, I suggest starting from scratch. ISSUES: You should not embed a full HTML page in your submenu page (view-banner.php). CSS and Javascript should be added with admin_enqueue_scripts and only in your plugin's page, not everywhere like it's happening now with the init action hook. I don't understand how you managed to make Ajax work, but it is surely not the proper way. STARTING AGAIN: Research the <plugin-development> tag at WordPress Answers, you'll find many nice examples of how to add your plugin page and render its contents. I always use this Plugin Class Demo from one of our moderators as starting point for a new plugin. Some working examples of Ajax in WordPress: [1], [2] and [3].

Categories : Wordpress

Wordpress Plugin Jquery Conflict Issue
I'm using http://trentrichardson.com/examples/timepicker/ in my ACF Date and Timepicker plugin, and I don't have any conflicts with WP jquery. Please see input_admin_enqueue_scripts() in date_time_picker-v4.php (in a non ACF add-on, replace the acf-datepicker dependency with jquery-ui-datepicker).

Categories : Jquery

Wordpress: Timezone issue of published field (Atom Publishing Protocol Plugin)
Replace get_publish_time() function in wp-content/plugins/atom-publishing-protocol/class-wp-atom-server.php with following code: /** * Retrieve published time to display in XML. * * @since 2.3.0 * * @param string $published Time string. * @return string */ function get_publish_time($published) { $pubtime = DateTime::createFromFormat(DateTime::RFC3339, $published); if (!$pubtime) { return array(current_time('mysql'),current_time('mysql',1)); } else { $localtime = $pubtime->format("Y-m-d H:i:s"); $pubtime->setTimezone( new DateTimeZone('UTC') ); $gmttime = $pubtime->format("Y-m-d H:i:s"); return array($localtime, $gmttime); } } Notice Requires PHP >= 5.2 If wp-app.php still exists, the plugin is not used. Reason

Categories : Wordpress

Wordpress Plugin not loading CSS on the plugin's option page in the admin menu
Figured it out... It was the line: add_action('admin_print_styles-'.$page, 'my_admin_enqueue_styles'); Since I'm doing all this inside a class, I need to pass the second parameter as an array with $this add_action('admin_print_styles-'.$page, array($this, 'my_admin_enqueue_styles')); I did it with the other hooks, just missed this since it's not done that way in the codex. Silly me.

Categories : Wordpress

Commit Failed While Uploading My Plugin to Wordpress Plugin Repository
I was having the same problem, and what solved it for me was to do the initial SVN Checkout to my local directory using https://plugins.svn.wordpress.org/[plugin-name] instead of http:// like I had been doing. After that, I was able to commit new changes and create new tag versions.

Categories : Wordpress

Wordpress Print Version | Access Wordpress core functions in a plugin
All WordPress functions are available in a plugin. The matter is hooking in the right place. Simple example: <?php /** * Plugin Name: Test Plugin */ // This hook is fired once WP, all plugins, and the theme are fully loaded and instantiated add_action( 'wp_loaded', 'plugin_so_18538270' ); function plugin_so_18538270() { // Admin area, do nothing if( is_admin() ) return; // "true" == $var // See Yoda Conditions: http://www.codinghorror.com/blog/2012/07/new-programming-jargon.html if( isset( $_GET['print'] ) && "true" == $_GET['print'] ) { // some code exit(); } } References: Writing_a_Plugin and Plugin_API at the Codex. Highest voted Questions in the <Plugin-Development> tag at WordPress Answers.

Categories : PHP

How to call WordPress plugin function without the entire plugin
So after some advanced Googling and trial and error, I figured it out: Note: before calling a function from a plugin, it is a good idea to check and make sure the plugin is activated. To do this with this particular plugin I used include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); if(is_plugin_active('widget-context/widget-context.php')){ ... } Next, this widget uses a php public class that already exists, so in order to use it again, I needed to set this class as an object to a variable like this; if(class_exists('widget_context')){ $my_widget_context = new widget_context(); } Next, some plugins require to load by executing a certain function. Again for the widget-context plugin, I needed: $my_widget_context->load_plugin_settings(); Now, I could succsessfully ca

Categories : PHP

Wordpress overloading PHP function from plugin A in plugin B
The best way to add functionality is to decompose the plugin and seperate the behaviours. If the plugin is not designed with extensibility and customizability in mind you're going to have a hard time, especially if you want updates to have no breaking changes. For instance: you might need access to a private function or property, you can't do that if you inherit/override. The function or property might even be gone when you update to a new version of the plugin. Inheriting from a class that is not abstract or designed to be inherited from is a code smell.

Categories : PHP

Eclipse plugin issue with CDT plugin
Eclipse does not uninstall a plugin (but just hides it from you), if there are dependencies from other plugins into your to be uninstalled plugins. For instance, if you have installed ADT with all plugins, then the Android Native Development Toolkit has a dependency to CDT and will therefore prohibit an uninstallation. If nothing else works, you may want to try a clean re-installation. That's quite easy (at least since 3.7 upwards): From your current installation, run File -> Export -> Installation -> To file. That will create a "receipe" of installed features. You can then install them using the same menu (under Import) into a clean Eclipse package and just leave the CDT away.

Categories : Java

Magento wishlist move to header
It seems you added to the wrong template file. Try adding <?php echo $this->getChildHtml('mini_wishlist_top'); ?> to template/page/html/header.phtml

Categories : Magento

Do want remove wishlist items when add all to cart
This one is handled in the Mage_Wishlist_Controller_Abstract on line 108: // Add to cart if ($item->addToCart($cart, $isOwner)) { $addedItems[] = $item->getProduct(); } as it is your personal Wishlist $isOwner is true and deletes the items. And as there is no way to override abstract classes, you have to copy the Abstract and IndexController in your own Module and do your modifications there. See here: http://stackoverflow.com/a/15742381/900326

Categories : Magento

Magento custom API for adding product wishlist
This may help you <?php $wishlist = Mage::getModel('wishlist/item')->load($_product->getId(),'product_id'); if($wishlist->getId()) //product is added echo "Added! - Product is in the wishlist!"; else //add product to wishlist echo "<a href='".$this->helper('wishlist')->getAddUrl($_product) ."'>Add This?</a>"; ;?> Mage::getModel('wishlist/item')->load($id)->delete(); http://abhijitberadeveloper.blogspot.in/2012/07/product-add-wishlist.html http://docs.magentocommerce.com/Mage_Wishlist/Mage_Wishlist_Helper_Data.html#methodgetWishlistItemCollection http://docs.magentocommerce.com/Mage_Wishlist/Mage_Wishlist_Helper_Data.htm

Categories : Magento

Wordpress Charts Plugin?
I would like to recommend you to take a look at Visualizer plugin. It is sophisticated tool to build neat and professional looking charts. This plugin allows you to upload CSV file or to use Google Spreadsheet document as data source. Take a read the plugin's knowledge base to figure out how to use it. A couple of screenshots:

Categories : Wordpress

Using AJAX in a WordPress plugin
You need to add an 'action' to your AJAX call. jQuery.ajax({ type: "POST", url: "/wp-admin/admin-ajax.php", data: newcontact, action: 'addcontact', success: function(data) { jQuery("#feedback").html(data); } }); The value should be the same as the add_action hook to wp_ajax. e.g. add_action( wp_action_{action_value}, 'myfunc' ); This allows WordPress to know which function to run when the AJAX call is made. This Codex page has some useful info and this article describes how to better refine the code you have.

Categories : PHP

SQL Export - Wordpress plugin DEV
It depends a little how your export_file() function is being called. But if it's called directly from an admin URL, you can add &noheader=1 to the URL. I use that successfully when generating an Excel file.

Categories : PHP

How to decode a WordPress plugin
It's hex encode and the reverse is this: http://ddecode.com/hexdecoder/?results=463d2f6124f0e50b67194fba93b8ab28 I really hate hate when programmers do this stupid kind of things! It's totally useless.

Categories : PHP

Magento: How to display how many times a product has been added to wishlist?
Use Below code it is working from my end to get total number of wish list added by all customer for particular prodduct $wishlist = Mage::getModel('wishlist/item')->getCollection(); $wishlist->getSelect() ->where('main_table.product_id = '.$_product->getId()); echo $count = $wishlist->count(); exit;

Categories : Magento

Magento - Display Wishlist button to registered users only
Try this: <button type="button" title="<?php echo $this->__('A&ntilde;adir todos a Lista de Compras') ?>" class="button btn-continue" onclick="setLocation('<?php echo $this->getUrl("checkout/cart/updatePost").$params?>')"><span><span><?php echo $this->__('A&ntilde;adir todo a Lista de Compras') ?></span></span></button>

Categories : Magento

Best way to set Wordpress plugin max version for update?
If you need to disable the plugins from updating you can simply use this plugin : http://wordpress.org/plugins/disable-wordpress-updates/ Regards

Categories : PHP

Load .js file from wordpress plugin
You can do like this using admin ajax : I will not explain the functions . you can google it and learn . Step 1: Localize some values for your script to be used in your javascript files, get admin-ajax.php url $author_nonce = wp_create_nonce( 'nk_author' ); wp_localize_script( 'nk_script', 'nk_object',array( 'nk_ajax_url' => admin_url( 'admin-ajax.php' ) , 'nk_plugin_url' => plugins_url() ,'nk_author' => $author_nonce) ); step 2 : In your script you can do this . var data = { action: 'nk_action', // the function that will be called in your plugin _ajax_nonce : nk_object.nk_author, // nonce for security id : 'mydata' //your data to be sent }; //(admin ajax url , your data , callback for response ) jQuery.post(nk_

Categories : Javascript

.click() not working in WordPress Plugin
Use jQuery event delegation for generated elements: $("#results").on('click','#addtoPlaylist',function(){ alert('clicked'); });

Categories : Jquery

WordPress Plugin Development - How to Set a Locale
Or does wordpress automatically selects a plugin language based on the WordPress installation? That's very much exactly what it does. You need to define the language in your config file (by defining WPLANG). WP picks it up from there and localizes strings the best it can according to your chosen locale.

Categories : PHP

zend framework 2 in wordpress plugin
I did exactly you need, I wrote a wordpress plugin allow you do that. If you still interested on this please consider visit my webpage about this, I would be glad to share with you In my web page there are many examples. I answered your another question on stackoverflow. your another question on stackoverflow my web page about this subject

Categories : PHP

wordpress plugin including javascript
I would suggest using wp_localize_script instead of attempting to dynamically generate your script. This will allow you to access any variables you build in your script within the rendered javascript. For example: wp_register_script('woo_tool_js', plugins_url('tooltip.js', __FILE__) ); wp_localize_script('woo_tool_js', 'my_data', array( 'key' => 'value' )); wp_enqueue_script('woo_tool_js'); ...will allow you to access the my_data array as an object in your javascript: console.log(my_data);

Categories : Jquery

How to create a fpdf wordpress plugin
The question is, how do you convert your html to pdf output? To get your PDF to look like your webpage, that is, with all the html+css, I don't believe this library will do it. If you just want to get the post_content from a post, and put it into a pdf, you could do this: To create a plugin: You'll need to add a folder to /wp-content/plugins/ and create your plugin file in that folder: /wp-content/plugins/fpdf/fpdf.php /* Plugin Name: fpdf Description: Post to PDF */ // Here's where you'll write your code. $post = get_post( $post_id ); require('fpdf.php'); $pdf = new FPDF(); $pdf->AddPage(); $pdf->SetFont('Arial','B',16); $pdf->Cell(40,10,$post->post_content); $pdf->Output(); This would output a pdf on every page load, after you activate the plugin, which is not li

Categories : Wordpress

how to get form posted value in wordpress plugin
You can pass variables like this function get_form_parameters($name, $email, $pass) { global $_POST; global $wp_query; // you can use direct these variables in function like echo $name, $email, $pass if (isset($wp_query->query_vars['action'])) { print $wp_query->query_vars['action']; exit(); } and use function like this where you want : get_form_parameters($_POST['name'], $_POST['email'], $_POST['pass']); if you have any doubt then please let me know

Categories : Wordpress

Cannot get WordPress plugin to paginate correctly
You should use wp_link_pages for the pagination. The for logged in users, use the_content filter to show the content without the pagination. e.g., in your post.php (or whatever template) file if( is_user_logged_in() ) : echo apply_filters( 'the_content', $post->post_content ); else : the_content(); wp_link_pages( $my_args ); endif;

Categories : PHP

Wordpress plugin, database not creating
Add this in your page, add_action('init','create_wispabb_table'); Or register_activation_hook(__FILE__, 'create_wispabb_table');

Categories : PHP

How to add a Bubble Notification to a WordPress plugin?
If you had researched for "bubble" at WordPress Answers, you'd have found, if not a solution, very good hints. From this Answer, an adapted example to add 10 to Advanced Custom Field plugin menu. Check the code comments: add_filter( 'add_menu_classes', 'add_plugin_bubble_so_17525062'); function add_plugin_bubble_so_17525062( $menu ) { $pending_count = 10; // Use your code to create this number foreach( $menu as $menu_key => $menu_data ) { // From the plugin URL http://example.com/wp-admin/edit.php?post_type=acf if( 'edit.php?post_type=acf' != $menu_data[2] ) continue; $menu[$menu_key][0] .= " <span class='update-plugins count-$pending_count'><span class='plugin-count'>" . number_format_i18n($pending_count) . '</span&g

Categories : PHP

HTML Gallery to Wordpress Plugin
This would be a good starting point: https://codex.wordpress.org/Writing_a_Plugin And this will take you through it step by step: http://net.tutsplus.com/tutorials/wordpress/creating-a-custom-wordpress-plugin-from-scratch/

Categories : HTML

How to add an auto refresh to a wordpress plugin?
The plugin is written in PHP but the loading and other stuff is handled with AJAX. There's a shout.js file and you can find the following line: setTimeout(function(){ myshouts_check_stream(); },5000); I think that's what you need :)

Categories : PHP

Wordpress Gravity Form Plugin [HELP]
I don't believe the routing will take into account AND conditions for the individual rules. You can however, use the following filter to do further modifications to the e-mail before it is being sent: add_filter("gform_notification", "my_custom_function", 10, 3); Or, for a specific form (i.e. id = 42): add_filter("gform_notification_42", "my_custom_function", 10, 3); Source: http://www.gravityhelp.com/documentation/page/Gform_notification Update An example of accessing the fields would look like this: add_filter('gform_notification_42', 'updateNotificationForForm42', 10, 3); function updateNotificationForForm42( $notification, $form, $entry ) { $fields = $form['fields']; foreach( $fields as $field ) { // Here you need to provide the field with some kind of identif

Categories : PHP

Wordpress- how to disable plugin update
In the plugin file, there will be a function that will check for updates. The original author could of named this anything, so you will have to go through the code and check each function and what it does. I would imagine the function will be quite obvious as to what it does. Alternatively you can add this to your plugin file: add_filter( 'http_request_args', 'dm_prevent_update_check', 10, 2 ); function dm_prevent_update_check( $r, $url ) { if ( 0 === strpos( $url, 'http://api.wordpress.org/plugins/update-check/' ) ) { $my_plugin = plugin_basename( __FILE__ ); $plugins = unserialize( $r['body']['plugins'] ); unset( $plugins->plugins[$my_plugin] ); unset( $plugins->active[array_search( $my_plugin, $plugins->active )] ); $r['body']['plug

Categories : Wordpress

jQuery plugin not loading in WordPress
You shouldn't be using wp_print_scripts. Use wp_enqueue_scripts instead. http://codex.wordpress.org/Plugin_API/Action_Reference/wp_print_scripts (this is for tying in your add_google_jquery and add_google_center functions) So, all you need to do is replace 'wp_print_scripts' with 'wp_enqueue_scripts' and you should be good to go

Categories : PHP

create widget for wordpress plugin
In your function getLosninger, you start an output buffer ( ob_start() ), but you don't do anything with it. You might be safe removing that line of code, or at least capturing the contents of the output buffer and flushing it.

Categories : Wordpress

wordpress plugin installation error
I have fixed the problem hence i am answering my own question. I have downloaded the latest version of php and compiled with "--with-zlib" option.It fixed the error . I dont know why because if my previous setup is not supporting zlip than it must through "php -r 'var_dump(function_exists("gzopen"));" false but it returned true. Thanks for all the help.

Categories : PHP

Wordpress rewrite url to plugin file
As the tag I was using not any of the type (e.g. posts, pages, category, author, search).. and also pretty urls may not be enabled on the wordpress . I cannot use add_rewrite_rule(); if I need to use add_rewrite_rule() then pretty urls must be enabled. So only way to rewrite the url is by editing the htaccess file. so this is the function which needs to be called to save the rules to htaccess on plugin activation function mod_rewrite_rules($rules) { $home_root = parse_url(home_url()); if ( isset( $home_root['path'] ) ) $home_root = trailingslashit($home_root['path']); else $home_root = '/'; $rules = array(); $rules[] = "<IfModule mod_rewrite.c>"; $rules[] = " RewriteEngine On"; $rules[] = " RewriteBase $home_root"; $rules[] = " RewriteRule ^oauth/fac

Categories : Wordpress

wordpress plugin to include files
Why are you sure the code is not correct? What is not working? What errors have you received? Please read the guidelines on asking questions. Some tips. The slugs for wp_register_script/style should be that - put them in lowercase and swap the spaces for - jQuery is loaded in noConflict mode (for good reason) by default. This means you should use 'jQuery' rather than '$' for your selectors. It's generally better to put your scripts in their own file and enqueue them like the others (that removes the need for the wp_head call.

Categories : Wordpress

Using $this when not in object context. wordpress plugin
use $this->render() instead of $this->class->render(); another is: add ucfirst because your class name is in first letter capital and you are passing small case in arguments. $this->controller = call_user_func_array(array(ucfirst($this->class), $this->method), $this->args)

Categories : PHP



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.