Search the Community
Showing results for tags 'wordpress'.
-
hello, on click this link, i am redirecting to page-listing-category.php page. and all listing are shown there. http://domain-name/listing-category/?a=hello but i want this link as http://domain-name/listing-category/hello ... i use this code in function.php add_rewrite_tag("%a%",'([0-9]+)'); $a = get_query_var("a"); // Wordpress way add_rewrite_rule('listing-category/([0-9]+)/?$', 'index.php?page_id=page-listing-category&a=$matches[1]', 'top'); add_rewrite_tag("%a%",'([0-9]+)'); add_rewrite_rule('listing-category/([0-9]+)/?$', 'index.php?page_id=page-listing-category&a=$matches[1]', 'top'); $wp_rewrite->flush_rules(); but, problem is the above isn't working ... can anypne suggest me something on this. ?? thanks.
- 4 replies
-
- url rewriting
- wordpress
-
(and 1 more)
Tagged with:
-
I'm trying to not show meta for an author based on is not user_nicename. The code below only works if there is just one user - how would I add another user to the code, so their meta is not shown as well? <?php if(get_the_author_meta( 'user_nicename')!='user1') : ?><div class="author clearfix"> <div class="author-gravatar"> <?php echo get_avatar( $post->post_author, 64 ); ?> </div> <div class="author-about"> <h4> <?php if(get_the_author_meta( 'first_name') != '' && get_the_author_meta( 'last_name') != '' ) : ?> <?php the_author_meta( 'first_name'); ?> <?php the_author_meta( 'last_name'); ?> <?php else: ?> <?php the_author_meta( 'user_nicename'); ?> <?php endif; ?> </h4> <p class="author-description"><?php the_author_meta( 'description' ); ?></p> </div> </div><?php endif ?>
-
Hello Friends, I am working as a Php Developer since last 5+ years. I have strong knowledge in Php/MySql, WordPress, Opencart and Magento. You can check my portfolio here..http://phpfreelancerszone.com/php-portfolio/ Contact Us By Email:[email protected] We can help on a moments notice via Skype: shailpatel05 Thanks.
-
Hi Guys Just to ask if do you know any code or module pluigin that i can have like this in my screenshot? (i attached it) thanks Please help i am using CMS - Wordpress, Joomla and even Drupal can any one please help me? thanks and Advance
-
Hi all I am having problems with french characters when using a custom function to upload posts from a database into wordpress Firstly here is my code: //This gets the values that is sent to the class to create post <?php require_once('wp-content/plugins/PostAdder/index.php'); try { $host = 'localhost'; //$dbname = 'wordpress'; $dbname = 'HotelWifi'; $user = 'root'; $pass = ''; $DBH = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING, PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8') ); } catch(PDOException $e) { echo $e->getMessage(); } $STH = $DBH->query('select * from activepropertylist'); $STH->setFetchMode(PDO::FETCH_ASSOC); while($row = $STH->fetch()) { $hotelname = ucwords(utf8_decode($row['Name'])); $city = $row['City']; $STH1 = $DBH->query('select * from wp_terms WHERE name = "' . $city . '"'); $STH1->setFetchMode(PDO::FETCH_ASSOC); while($row1 = $STH1->fetch()) { $cat = $row1['term_id']; } $tcat = array($cat); post_a_newhotel($hotelname, $tcat) ; } ?> // this is the function that fills the class and calls the wp_insert_post function <?php /* Plugin Name: POstHotel Plugin URI: http://www.hotelwifiscore.com Description: Creates post from supplied data Version: 1 Author: davegrix Author URI: http://www.hotelwifiscore.com */ require_once('wp-load.php'); class wm_mypost { var $post_title; var $post_category; } function post_a_newhotel($title, $post_cat) { if (class_exists('wm_mypost')) { $myclass = new wm_mypost(); } else { class wm_mypost { var $post_title; var $post_category; } } // initialize post object $wm_mypost = new wm_mypost(); // fill object $wm_mypost->post_title = utf8_decode($title); $wm_mypost->post_category = $post_cat; $wm_mypost->post_status = 'publish'; array_walk_recursive($wm_mypost, function (&$value) { $value = htmlspecialchars(html_entity_decode($value, ENT_QUOTES, 'UTF-8'), ENT_QUOTES, 'UTF-8'); } ); wp_insert_post($wm_mypost); } ?> The string I am having problems with is 'Best Western Premier Hôtel L'Aristocrate' The result stored using the above is: Best Western Premier H?tel L'Aristocrate database is set to utf8_general_ci Can anyone shine any light on what to do?
- 5 replies
-
- wordpress
- wp_insert_post
-
(and 1 more)
Tagged with:
-
Overview: Sort unique string from an array and display results into a variable which can be echoed into jQuery to be displayed as a graph. I using Wordpress with a repeater from custom post fields plugin, code below: $repeater = get_field('treatments'); foreach( $repeater as $key => $row ) { column_id[ $key ] = $row['treatment_name']; } array_multisort( $column_id, SORT_ASC, $repeater ); foreach( $repeater as $row ) { print_r($row); } The print_r returns.. Array ( [treatment_name] => back pain [pain_level] => 4 ) Array ( [treatment_name] => back pain [pain_level] => 5 ) Array ( [treatment_name] => back pain [pain_level] => 7 ) Array ( [treatment_name] => back pain [pain_level] => 10 ) Array ( [treatment_name] => shoulder pain [pain_level] => 3 ) Array ( [treatment_name] => shoulder pain [pain_level] => 8 ) Array ( [treatment_name] => shoulder pain [pain_level] => 10 ) I wish to be able to sort the array data into a variable I can using within JS. { treatment: '1', a: 4, b: 3 }, { treatment: '2', a: 5, b: 8 }, { treatment: '3', a: 7, b: 10 }, { treatment: '4', b: 10 }, A = back pain B = shoulder pain [treatment_name] - is a text field, so I looking for every unique [treatment_name] to added for example having one treatment called 'foot ache' with the pain level of 6 would be added to the start of the list as C. e.g. { treatment: '1', a: 4, b: 3, c: 6 }, { treatment: '2', a: 5, b: 8 }, { treatment: '3', a: 7, b: 10 }, { treatment: '4', b: 10 }, I have gone over and over trying to work the logic out but seems my level of php is not up to par, so I thought no better place to asked then the people who got me this far.. Any questions please do let me know, and anyone will to help your a star..
-
I was wondering if there is a way to switch the display of woocommerce hooks on my single product page shop. I would like to remove: add_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 ); and replace that with my product description. Here is my Woocommerce-hooks.php file. Any help would be greatly appreciated. <?php /** * WooCommerce Hooks * * Action/filter hooks used for WooCommerce functions/templates * * @author WooThemes * @category Core * @package WooCommerce/Templates * @version 1.6.4 */ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly /** Template Hooks ********************************************************/ if ( ! is_admin() || defined('DOING_AJAX') ) { /** * Content Wrappers * * @see woocommerce_output_content_wrapper() * @see woocommerce_output_content_wrapper_end() */ add_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 ); add_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 ); /** * Sale flashes * * @see woocommerce_show_product_loop_sale_flash() * @see woocommerce_show_product_sale_flash() */ add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10 ); add_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_sale_flash', 10 ); /** * Breadcrumbs * * @see woocommerce_breadcrumb() */ add_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 ); /** * Sidebar * * @see woocommerce_get_sidebar() */ add_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 ); /** * Archive descriptions * * @see woocommerce_taxonomy_archive_description() * @see woocommerce_product_archive_description() */ add_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description', 10 ); add_action( 'woocommerce_archive_description', 'woocommerce_product_archive_description', 10 ); /** * Products Loop * * @see woocommerce_show_messages() * @see woocommerce_result_count() * @see woocommerce_catalog_ordering() */ add_action( 'woocommerce_before_shop_loop', 'woocommerce_show_messages', 10 ); add_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 ); add_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 ); /** * Product Loop Items * * @see woocommerce_show_messages() * @see woocommerce_template_loop_add_to_cart() * @see woocommerce_template_loop_product_thumbnail() * @see woocommerce_template_loop_price() * @see woocommerce_template_loop_rating() */ add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 ); add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 ); add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 ); add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5 ); /** * Subcategories * * @see woocommerce_subcategory_thumbnail() */ add_action( 'woocommerce_before_subcategory_title', 'woocommerce_subcategory_thumbnail', 10 ); /** * Before Single Products * * @see woocommerce_show_messages() */ add_action( 'woocommerce_before_single_product', 'woocommerce_show_messages', 10 ); /** * Before Single Products Summary Div * * @see woocommerce_show_product_images() * @see woocommerce_show_product_thumbnails() */ add_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 ); add_action( 'woocommerce_product_thumbnails', 'woocommerce_show_product_thumbnails', 20 ); /** * After Single Products Summary Div * * @see woocommerce_output_product_data_tabs() * @see woocommerce_upsell_display() * @see woocommerce_output_related_products() */ add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 ); add_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 ); add_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 ); /** * Product Summary Box * * @see woocommerce_template_single_title() * @see woocommerce_template_single_price() * @see woocommerce_template_single_excerpt() * @see woocommerce_template_single_meta() * @see woocommerce_template_single_sharing() */ add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 ); add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 ); add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 ); add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 ); add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_sharing', 50 ); /** * Product Add to cart * * @see woocommerce_template_single_add_to_cart() * @see woocommerce_simple_add_to_cart() * @see woocommerce_grouped_add_to_cart() * @see woocommerce_variable_add_to_cart() * @see woocommerce_external_add_to_cart() */ add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 ); add_action( 'woocommerce_simple_add_to_cart', 'woocommerce_simple_add_to_cart', 30 ); add_action( 'woocommerce_grouped_add_to_cart', 'woocommerce_grouped_add_to_cart', 30 ); add_action( 'woocommerce_variable_add_to_cart', 'woocommerce_variable_add_to_cart', 30 ); add_action( 'woocommerce_external_add_to_cart', 'woocommerce_external_add_to_cart', 30 ); /** * Pagination after shop loops * * @see woocommerce_pagination() */ add_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 10 ); /** * Product page tabs */ add_filter( 'woocommerce_product_tabs', 'woocommerce_default_product_tabs' ); add_filter( 'woocommerce_product_tabs', 'woocommerce_sort_product_tabs', 99 ); /** * Checkout * * @see woocommerce_checkout_login_form() * @see woocommerce_checkout_coupon_form() * @see woocommerce_order_review() */ add_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_login_form', 10 ); add_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 ); add_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 ); /** * Cart * * @see woocommerce_cross_sell_display() */ add_action( 'woocommerce_cart_collaterals', 'woocommerce_cross_sell_display' ); /** * Footer * * @see woocommerce_demo_store() */ add_action( 'wp_footer', 'woocommerce_demo_store' ); /** * Order details * * @see woocommerce_order_details_table() * @see woocommerce_order_details_table() */ add_action( 'woocommerce_view_order', 'woocommerce_order_details_table', 10 ); add_action( 'woocommerce_thankyou', 'woocommerce_order_details_table', 10 ); } /** Store Event Hooks *****************************************************/ /** * Shop Page Handling and Support * * @see woocommerce_template_redirect() * @see woocommerce_nav_menu_item_classes() * @see woocommerce_list_pages() */ add_action( 'template_redirect', 'woocommerce_template_redirect' ); add_filter( 'wp_nav_menu_objects', 'woocommerce_nav_menu_item_classes', 2, 20 ); add_filter( 'wp_list_pages', 'woocommerce_list_pages' ); /** * Logout link * * @see woocommerce_nav_menu_items() */ add_filter( 'wp_nav_menu_objects', 'woocommerce_nav_menu_items', 10, 2 ); /** * Clear the cart * * @see woocommerce_empty_cart() * @see woocommerce_clear_cart_after_payment() */ if ( get_option( 'woocommerce_clear_cart_on_logout' ) == 'yes' ) add_action( 'wp_logout', 'woocommerce_empty_cart' ); add_action( 'get_header', 'woocommerce_clear_cart_after_payment' ); /** * Disable admin bar * * @see woocommerce_disable_admin_bar() */ add_filter( 'show_admin_bar', 'woocommerce_disable_admin_bar', 10, 1 ); /** * Cart Actions * * @see woocommerce_update_cart_action() * @see woocommerce_add_to_cart_action() * @see woocommerce_load_persistent_cart() */ add_action( 'init', 'woocommerce_update_cart_action' ); add_action( 'init', 'woocommerce_add_to_cart_action' ); add_action( 'wp_login', 'woocommerce_load_persistent_cart', 1, 2 ); /** * Checkout Actions * * @see woocommerce_checkout_action() * @see woocommerce_pay_action() */ add_action( 'init', 'woocommerce_checkout_action', 20 ); add_action( 'init', 'woocommerce_pay_action', 20 ); /** * Login and Registration * * @see woocommerce_process_login() * @see woocommerce_process_registration() */ add_action( 'init', 'woocommerce_process_login' ); add_action( 'init', 'woocommerce_process_registration' ); /** * Product Downloads * * @see woocommerce_download_product() */ add_action('init', 'woocommerce_download_product'); /** * Analytics * * @see woocommerce_ecommerce_tracking_piwik() */ add_action( 'woocommerce_thankyou', 'woocommerce_ecommerce_tracking_piwik' ); /** * RSS Feeds * * @see woocommerce_products_rss_feed() */ add_action( 'wp_head', 'woocommerce_products_rss_feed' ); /** * Order actions * * @see woocommerce_cancel_order() * @see woocommerce_order_again() */ add_action( 'init', 'woocommerce_cancel_order' ); add_action( 'init', 'woocommerce_order_again' ); /** * Star Ratings * * @see woocommerce_add_comment_rating() * @see woocommerce_check_comment_rating() */ add_action( 'comment_post', 'woocommerce_add_comment_rating', 1 ); add_filter( 'preprocess_comment', 'woocommerce_check_comment_rating', 0 ); /** * Filters */ add_filter( 'woocommerce_short_description', 'wptexturize' ); add_filter( 'woocommerce_short_description', 'convert_smilies' ); add_filter( 'woocommerce_short_description', 'convert_chars' ); add_filter( 'woocommerce_short_description', 'wpautop' ); add_filter( 'woocommerce_short_description', 'shortcode_unautop' ); add_filter( 'woocommerce_short_description', 'prepend_attachment' ); add_filter( 'woocommerce_short_description', 'do_shortcode', 11 ); // AFTER wpautop() woocommerce-hooks.php
-
- woocommerce
- hooks
-
(and 2 more)
Tagged with:
-
As a software engineer the candidate will be part of a team that builds scalable web applications using open source technologies such as PHP, Ruby and Python. The developer will be building applications in multiple verticals for mission critical systems with high precision providing them a challenging environment to work in. The developer will also have to be a fast learner to get acquainted to the rapid changes in the technology. A. Primary Skills: · 3+ Years of experience in open source development with PHP . · Good experience with Javascript and javascript libraries like jquery. · Good understanding of Object oriented concepts. · Good understanding of programming fundamentals and design patterns. · Experience with MVC framework, Open Source, CMS. (Wordpress, joomla, drupal etc) B.Secondary Skills: · Experience in any other additional open source server side programming language like ruby or python. · Experience with client side MVC frameworks will be a plus. · Good Communication Skills . Experience : 3+ years Job / Project Experience : Development Educational Background : BE(IT/CSc), B Tech, MCA Salary Range : As per Co.Norms (based on last drawn CTC) If you are interested,drop your profile at [email protected]
-
Hello everyone i'm creating my first widget but i need help... The problem i'm facing is that whenever i activate the plugin it shows the success message and also shows in the widgets area but the page not showing in the correct manner... Like if page has php error then it stops loading certain parts of the page... I have attached the screenshots of the widget page... The code is shown below <?php /* Plugin Name: My First Widget Description: This is my first plugin. Plugin URI: www.abc.com Version: 1.0.2 Author: Subhomoy Goswami Author URI: www.cde.com */ class my_first_plugin extends WP_Widget { function my_first_plugin() { //parent::__construct(false,$name=__('My First Widget')); $widget_ops = array('classname'=>'example', 'description'=>__('This will just show the Title of the widget'),'id_base'=>'my_first_plugin'); $this->WP_Widget('my_first_plugin',__('My First Widget')); } /* This will be displayed in the backend of the website i.e The Admin */ public function form($instance) { if((isset($instance['name'])) && (isset($instance['email']))) { $name = $instance['name']; $email = $instance['email']; } else { $name = __('','bc_widget_title'); $email = __('','bc_widget_title'); } ?> <p>Name : <input type="text" name="<?php echo $this->get_field_name('name'); ?>" value="<?php echo $this->esc_attr($name); ?>"</p> <p>Email : <input type="text" name="<?php echo $this->get_field_name('email'); ?>" value="<?php echo $this->esc_attr($email); ?>"</p> <?php } /* This is the place where the update takes place */ public function update($new_instance, $old_instance) { $instance = $old_instance; $instance['name'] = (!empty($new_instance['name']))? strip_tags($new_instance['name']):''; $instance['email'] = (!empty($new_instance['email']))? strip_tags($new_instance['email']):''; return $instance; } /* This will be displayed in the web page*/ public function widget($args,$instance) { extract($args); echo $before_widget; $name = apply_filters('widget_title',$instance['name']); $email = empty($instance['email'])? ' ' : $instance['email']; if(!empty($instance['name'])) {echo $before_title.$name.$after_title;} echo "<p>Name =".$instance['name']."</p>"; echo "<p>Email =".$instance['email']."</p>"; echo $after_widget; } } add_action('widgets_init',function(){ register_widget('my_first_plugin'); }); ?> Any help will be greatly appreciated....
-
I realized that my previous question wasn't clear enough so i decided to open a new thread (hopefully the old one will be removed - sorry for inconvinience). Here's my question - I got an extern html form that passes a value to some php file that is called makelist.php - The makelist.php simply analyzes the data that was sent through the $_POST method and puts all the 'right' values in one string array that is called $arrinfo - Each value there is a simple html snippet like '<a href=http://www.mywebsite.com/tes2t>testing</a>' . Now, assuming that i have an existing wordpress page which is called 'test1' for example - How can i put -all- that links (snippets) that exist in $arrinfo into a new sub page which will be like www.mywebsite.com/test1/arrinfolinks/ ? Do i need to install any wordpress plugin that will allow me to insert PHP code within posts/pages? Or is there any way to do it externally out of my php code? I can definitely put my php files in the same directory that wordpress uses so i can use wp_insert_post() for example - but i just couldn't figure yet how to create a sub page and insert all $arrinfo's content into it so it will be shown as links and not plain text of html tags.. thanks in advance..
-
Hello, Is there any way to -remotely- insert a post to a custom wordpress URL? Assuming I have a network of 5 websites and i would like to update all of them through some form i'll build (may say - a mini CMS maybe). Site 1 - [Form for content] [submit button] Site 2 - [Form2 for content] [[submit button]] Site 3 - [Form3 for content] [submit button] ... and so on. And simply everytime i'll pust the submit button the Form3 content will go to a specific wordpress website, and same about Form2 and Form1. Thanks.
-
Is it possible to have a WordPress website that you can do so that you can play Angry Birds on it? I searched the internet and couldn't find an answer. Also, it appears there are no plugins for it. Thanks colleagues!
-
Hello friends, My name Stefany and I am a computer programmer. Over the past 2 years I have created 15 websites, the most prominent being: 1. Social Network for the Texas Tech University; 2. Web-shop for a 4d Go player; 3. Personal history blog; 4. Another web-shop for a Bulgarian company; 5. Homepage for a Bulgarian national newspaper; My major skills include: Front end - XHTML, CSS, JavaScript Back end - PHP, Perl, AJAX Databases - MySQL, SQLite, MariaDB CMS - WordPress Other - XML, REST, SOAP Frameworks - CodeIgniter E-Commerce platforms - OsCommerce, Magento I am truly confident to create any kind of website, web application or script. Just send me a message, thank you. Portfolio with all the websites I had created so far and my programming blog - www.dyulgerova.info Github - https://github.com/Stefany93?tab=repositories CV - www.dyulgerova.info/cv.pdf Email: [email protected] Skype - age_of_empires3 Thank you very much! Stefany
-
require_once ("paypalfunctions.php"); $PaymentOption = "PayPal"; if ( $PaymentOption == "PayPal") { // ================================== // PayPal Express Checkout Module // ================================== //'------------------------------------ //' The paymentAmount is the total value of //' the purchase. //' //' TODO: Enter the total Payment Amount within the quotes. //' example : $paymentAmount = "15.00"; //'------------------------------------ $paymentAmount = "99"; //'------------------------------------ //' The currencyCodeType //' is set to the selections made on the Integration Assistant //'------------------------------------ $currencyCodeType = "USD"; $paymentType = "Sale"; //'------------------------------------ //' The returnURL is the location where buyers return to when a //' payment has been succesfully authorized. //' //' This is set to the value entered on the Integration Assistant //'------------------------------------ $returnURL = "http://127.0.0.1/digitalgoodsexample/orderconfirm.php"; //'------------------------------------ //' The cancelURL is the location buyers are sent to when they hit the //' cancel button during authorization of payment during the PayPal flow //' //' This is set to the value entered on the Integration Assistant //'------------------------------------ $cancelURL = "http://127.0.0.1/digitalgoodsexample/cancel.php"; //'------------------------------------ //' Calls the SetExpressCheckout API call //' //' The CallSetExpressCheckout function is defined in the file PayPalFunctions.php, //' it is included at the top of this file. //'------------------------------------------------- $items = array(); $items[] = array('name' => 'PayPal Digital Goods Integration Guide', 'amt' => $paymentAmount, 'qty' => 1); //::ITEMS:: // to add anothe item, uncomment the lines below and comment the line above // $items[] = array('name' => 'Item Name1', 'amt' => $itemAmount1, 'qty' => 1); // $items[] = array('name' => 'Item Name2', 'amt' => $itemAmount2, 'qty' => 1); // $paymentAmount = $itemAmount1 + $itemAmount2; // assign corresponding item amounts to "$itemAmount1" and "$itemAmount2" // NOTE : sum of all the item amounts should be equal to payment amount $resArray = SetExpressCheckoutDG( $paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $items ); $ack = strtoupper($resArray["ACK"]); if($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { $token = urldecode($resArray["TOKEN"]); RedirectToPayPalDG( $token ); } else { //Display a user friendly Error on the page using any of the following error information returned by PayPal $ErrorCode = urldecode($resArray["L_ERRORCODE0"]); $ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]); $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]); $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]); echo "SetExpressCheckout API call failed. "; echo "Detailed Error Message: " . $ErrorLongMsg; echo "Short Error Message: " . $ErrorShortMsg; echo "Error Code: " . $ErrorCode; echo "Error Severity Code: " . $ErrorSeverityCode; } }<code>I am using the above paypal function to send users to paypal for payment. However, I would like to automatically insert the product price on the line:</code>$paymentAmount = "99"<code>instead of numeric value using a meta value that is:</code>echo get_post_meta($post->ID, 'download_info_price', true I am have been perfectly able to make the paypal functions work, but only with numeric value by using it as a template page for my checkout page. I believe that I need something that help me echo meta value outside of the loop and using:`global $wp_query; $postid = $wp_query->post->ID; echo get_post_meta($postid, 'Your-Custom-Field', true);`did not get me anywhere. with the above, I tried calling /wp-load.php in the paypal functions, but no result. The price/amount I want to automate is require by my paypal checkout file that is called on the header of above codesrequire_once ("paypalfunctions.php")the paypal checkout is:`/******************************************** PayPal API Module Defines all the global variables and the wrapper functions ********************************************/ $PROXY_HOST = '127.0.0.1'; $PROXY_PORT = '808'; $SandboxFlag = true; //' TODO: //'------------------------------------ //' PayPal API Credentials //' Replace <API_USERNAME> with your API Username //' Replace <API_PASSWORD> with your API Password //' Replace <API_SIGNATURE> with your Signature //'------------------------------------ $API_UserName=//this is hidden; $API_Password=//this is hidden; $API_Signature=//this is hidden; // BN Code is only applicable for partners $sBNCode = "PP-ECWizard"; /* ' Define the PayPal Redirect URLs. ' This is the URL that the buyer is first sent to do authorize payment with their paypal account ' change the URL depending if you are testing on the sandbox or the live PayPal site ' ' For the sandbox, the URL is https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token= ' For the live site, the URL is https://www.paypal.com/webscr&cmd=_express-checkout&token= */ if ($SandboxFlag == true) { $API_Endpoint = "https://api-3t.sandbox.paypal.com/nvp"; $PAYPAL_URL = "https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token="; $PAYPAL_DG_URL = "https://www.sandbox.paypal.com/incontext?token="; } else { $API_Endpoint = "https://api-3t.paypal.com/nvp"; $PAYPAL_URL = "https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token="; $PAYPAL_DG_URL = "https://www.paypal.com/incontext?token="; } $USE_PROXY = false; $version = "84"; /* An express checkout transaction starts with a token, that identifies to PayPal your transaction In this example, when the script sees a token, the script knows that the buyer has already authorized payment through paypal. If no token was found, the action is to send the buyer to PayPal to first authorize payment */ /* '------------------------------------------------------------------------------------------------------------------------------------------- ' Purpose: Prepares the parameters for the SetExpressCheckout API Call for a Digital Goods payment. ' Inputs: ' paymentAmount: Total value of the shopping cart ' currencyCodeType: Currency code value the PayPal API ' paymentType: paymentType has to be one of the following values: Sale or Order or Authorization ' returnURL: the page where buyers return to after they are done with the payment review on PayPal ' cancelURL: the page where buyers return to when they cancel the payment review on PayPal '-------------------------------------------------------------------------------------------------------------------------------------------- */ function SetExpressCheckoutDG( $paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $items) { //------------------------------------------------------------------------------------------------------------------------------------ // Construct the parameter string that describes the SetExpressCheckout API call in the shortcut implementation $nvpstr = "&PAYMENTREQUEST_0_AMT=". $paymentAmount; $nvpstr .= "&PAYMENTREQUEST_0_PAYMENTACTION=" . $paymentType; $nvpstr .= "&RETURNURL=" . $returnURL; $nvpstr .= "&CANCELURL=" . $cancelURL; $nvpstr .= "&PAYMENTREQUEST_0_CURRENCYCODE=" . $currencyCodeType; $nvpstr .= "&REQCONFIRMSHIPPING=0"; $nvpstr .= "&NOSHIPPING=1"; foreach($items as $index => $item) { $nvpstr .= "&L_PAYMENTREQUEST_0_NAME" . $index . "=" . urlencode($item["name"]); $nvpstr .= "&L_PAYMENTREQUEST_0_AMT" . $index . "=" . urlencode($item["amt"]); $nvpstr .= "&L_PAYMENTREQUEST_0_QTY" . $index . "=" . urlencode($item["qty"]); $nvpstr .= "&L_PAYMENTREQUEST_0_ITEMCATEGORY" . $index . "=Digital"; } //'--------------------------------------------------------------------------------------------------------------- //' Make the API call to PayPal //' If the API call succeded, then redirect the buyer to PayPal to begin to authorize payment. //' If an error occured, show the resulting errors //'--------------------------------------------------------------------------------------------------------------- $resArray = hash_call("SetExpressCheckout", $nvpstr); $ack = strtoupper($resArray["ACK"]); if($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { $token = urldecode($resArray["TOKEN"]); $_SESSION['TOKEN'] = $token; } return $resArray; } /* '------------------------------------------------------------------------------------------- ' Purpose: Prepares the parameters for the GetExpressCheckoutDetails API Call. ' ' Inputs: ' None ' Returns: ' The NVP Collection object of the GetExpressCheckoutDetails Call Response. '------------------------------------------------------------------------------------------- */ function GetExpressCheckoutDetails( $token ) { //'-------------------------------------------------------------- //' At this point, the buyer has completed authorizing the payment //' at PayPal. The function will call PayPal to obtain the details //' of the authorization, incuding any shipping information of the //' buyer. Remember, the authorization is not a completed transaction //' at this state - the buyer still needs an additional step to finalize //' the transaction //'-------------------------------------------------------------- //'--------------------------------------------------------------------------- //' Build a second API request to PayPal, using the token as the //' ID to get the details on the payment authorization //'--------------------------------------------------------------------------- $nvpstr="&TOKEN=" . $token; //'--------------------------------------------------------------------------- //' Make the API call and store the results in an array. //' If the call was a success, show the authorization details, and provide //' an action to complete the payment. //' If failed, show the error //'--------------------------------------------------------------------------- $resArray=hash_call("GetExpressCheckoutDetails",$nvpstr); $ack = strtoupper($resArray["ACK"]); if($ack == "SUCCESS" || $ack=="SUCCESSWITHWARNING") { return $resArray; } else return false; } /* '------------------------------------------------------------------------------------------------------------------------------------------- ' Purpose: Prepares the parameters for the GetExpressCheckoutDetails API Call. ' ' Inputs: ' sBNCode: The BN code used by PayPal to track the transactions from a given shopping cart. ' Returns: ' The NVP Collection object of the GetExpressCheckoutDetails Call Response. '-------------------------------------------------------------------------------------------------------------------------------------------- */ function ConfirmPayment( $token, $paymentType, $currencyCodeType, $payerID, $FinalPaymentAmt, $items ) { /* Gather the information to make the final call to finalize the PayPal payment. The variable nvpstr holds the name value pairs */ $token = urlencode($token); $paymentType = urlencode($paymentType); $currencyCodeType = urlencode($currencyCodeType); $payerID = urlencode($payerID); $serverName = urlencode($_SERVER['SERVER_NAME']); $nvpstr = '&TOKEN=' . $token . '&PAYERID=' . $payerID . '&PAYMENTREQUEST_0_PAYMENTACTION=' . $paymentType . '&PAYMENTREQUEST_0_AMT=' . $FinalPaymentAmt; $nvpstr .= '&PAYMENTREQUEST_0_CURRENCYCODE=' . $currencyCodeType . '&IPADDRESS=' . $serverName; foreach($items as $index => $item) { $nvpstr .= "&L_PAYMENTREQUEST_0_NAME" . $index . "=" . urlencode($item["name"]); $nvpstr .= "&L_PAYMENTREQUEST_0_AMT" . $index . "=" . urlencode($item["amt"]); $nvpstr .= "&L_PAYMENTREQUEST_0_QTY" . $index . "=" . urlencode($item["qty"]); $nvpstr .= "&L_PAYMENTREQUEST_0_ITEMCATEGORY" . $index . "=Digital"; } /* Make the call to PayPal to finalize payment If an error occured, show the resulting errors */ $resArray=hash_call("DoExpressCheckoutPayment",$nvpstr); /* Display the API response back to the browser. If the response from PayPal was a success, display the response parameters' If the response was an error, display the errors received using APIError.php. */ $ack = strtoupper($resArray["ACK"]); return $resArray; } /** '------------------------------------------------------------------------------------------------------------------------------------------- * hash_call: Function to perform the API call to PayPal using API signature * @methodName is name of API method. * @nvpStr is nvp string. * returns an associtive array containing the response from the server. '------------------------------------------------------------------------------------------------------------------------------------------- */ function hash_call($methodName,$nvpStr) { //declaring of global variables global $API_Endpoint, $version, $API_UserName, $API_Password, $API_Signature; global $USE_PROXY, $PROXY_HOST, $PROXY_PORT; global $gv_ApiErrorURL; global $sBNCode; //setting the curl parameters. $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$API_Endpoint); curl_setopt($ch, CURLOPT_VERBOSE, 1); //turning off the server and peer verification(TrustManager Concept). curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_POST, 1); //if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled. //Set proxy name to PROXY_HOST and port number to PROXY_PORT in constants.php if($USE_PROXY) curl_setopt ($ch, CURLOPT_PROXY, $PROXY_HOST. ":" . $PROXY_PORT); //NVPRequest for submitting to server $nvpreq="METHOD=" . urlencode($methodName) . "&VERSION=" . urlencode($version) . "&PWD=" . urlencode($API_Password) . "&USER=" . urlencode($API_UserName) . "&SIGNATURE=" . urlencode($API_Signature) . $nvpStr . "&BUTTONSOURCE=" . urlencode($sBNCode); //setting the nvpreq as POST FIELD to curl curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq); //getting response from server $response = curl_exec($ch); //convrting NVPResponse to an Associative Array $nvpResArray=deformatNVP($response); $nvpReqArray=deformatNVP($nvpreq); $_SESSION['nvpReqArray']=$nvpReqArray; if (curl_errno($ch)) { // moving to display page to display curl errors $_SESSION['curl_error_no']=curl_errno($ch) ; $_SESSION['curl_error_msg']=curl_error($ch); //Execute the Error handling module to display errors. } else { //closing the curl curl_close($ch); } return $nvpResArray; } /*'---------------------------------------------------------------------------------- Purpose: Redirects to PayPal.com site. Inputs: NVP string. Returns: ---------------------------------------------------------------------------------- */ function RedirectToPayPal ( $token ) { global $PAYPAL_URL; // Redirect to paypal.com here $payPalURL = $PAYPAL_URL . $token; header("Location: ".$payPalURL); exit; } function RedirectToPayPalDG ( $token ) { global $PAYPAL_DG_URL; // Redirect to paypal.com here $payPalURL = $PAYPAL_DG_URL . $token; header("Location: ".$payPalURL); exit; } /*'---------------------------------------------------------------------------------- * This function will take NVPString and convert it to an Associative Array and it will decode the response. * It is usefull to search for a particular key and displaying arrays. * @nvpstr is NVPString. * @nvpArray is Associative Array. ---------------------------------------------------------------------------------- */ function deformatNVP($nvpstr) { $intial=0; $nvpArray = array(); while(strlen($nvpstr)) { //postion of Key $keypos= strpos($nvpstr,'='); //position of value $valuepos = strpos($nvpstr,'&') ? strpos($nvpstr,'&'): strlen($nvpstr); /*getting the Key and Value values and storing in a Associative Array*/ $keyval=substr($nvpstr,$intial,$keypos); $valval=substr($nvpstr,$keypos+1,$valuepos-$keypos-1); //decoding the respose $nvpArray[urldecode($keyval)] =urldecode( $valval); $nvpstr=substr($nvpstr,$valuepos+1,strlen($nvpstr)); } return $nvpArray; }
-
Hello. Im new to this forum. So hi everyone. ^^ Im wondering if you guys could tell me how could i add content from this Link on to the front site of my page (which is wordpress) www.zapumpo.si. Thank you to everyone wholl try to help!
- 2 replies
-
- wordpress
- content from page to my page
- (and 3 more)
-
I'm currently working on a WordPress website project and I am hoping someone can help me out on this. In the registration page, the data entered is stored into the WordPress database. I've also build a connection to store those data into an external database as well. So basically, If a visitor registers on the site, their data info is stored in the WP and external DB. My question is since the external DB relies on checking to see if the submit button has been pressed, do those data input values need to be escaped to prevent sql injection into the external DB since the data submitted to WordPress has already been sql escaped? Thanks for helping.
-
I would like someone to please help look over these lines of codes and help me correct what's wrong with it. The first problem I found out on my registration form is when a user fills out a portion of the form, the WordPress client side and server side validation works as intended but that data gets processed/stored into my external database which it is not suppose to. So what I did to prevent it check if the user pressed the submit button, if it's pressed, check to see if the values aren't empty. If the values are empty, do something and stop the connection but If the values are not empty, run the connection to the external DB using the try/catch statement. I tested it out again and the validation works as intended, no data was processed but when the user completes the registration form correctly, their info gets stored into the WordPress DB but not my external database. Can anyone please help me with this issue? <?php $firstname = esc_attr($_POST['fname']); $lastname= esc_attr($_POST['lname']); $email= esc_attr($_POST['email']); ... $error = false; $required = array($firstname, $lastname, $email ...); if (!isset($_POST['on-reg-submit'])) { // Do nothing } else { foreach($required as $val) { if (empty($_POST[$val])) { $error = true; } } if ($error) { // If errors, prevent from submmiting to external DB } else { // No errors try { // Here is where I connect to the external DB // processing the posts values into it and storing the post values into my external DB } catch { echo "ERROR!"; } } ....
-
- if/elsetry/catch
- form submit
-
(and 1 more)
Tagged with:
-
Hi, I'm working on a reset password for WordPress and I'm stumped on this query. What the query does is when a user requests a password reset, the query makes an update to the user's password and activation key. When I run this query, it's giving me int(0) which is saying there are no rows affected. I ran a var_dump on each POST variables to check if the values are correct and it is, so I'm not sure where the error is coming from this sql statement. $resetQuery = $wpdb -> query($wpdb -> prepare("UPDATE wp_users SET user_pass = %s, user_activation_key = '' WHERE user_login = %s AND user_activation_key = %s" , $hashedPwd , $usernameemail, $key)); If anyone can please assist me, that would be great! -Halben
-
Below is the code for my Latest post Widget, I want to configure the widget to exclude 4 previous post and add paginationat the bottom instead of the load more function. I know that <?php query_posts('posts_per_page=12&offset=4'); if(have_posts():while (have_posts(): the_post()p ?> will work. I need to configure the below code to allow me to exclude posts and not loadmore. Thanks In advanced! --------------------------------------------------------------------------------- <?php class wpShowerIndexLatestEntriesWidget extends WP_Widget { function __construct() { parent::__construct( 'wpshower_index_latest_entries', 'Homepage Latest Entries', array('description' => __('Widget for displaying latest entries', 'outspoken')) ); } /** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget($args, $instance) { extract($args); $limit = $instance['limit']; $options = array( 'posts_per_page' => $limit + 1 ); $exclude = wpShower::getIndexPosts('exclude'); if (!empty($exclude)) $options['exclude'] = implode(',', $exclude); $posts = get_posts($options); $title = apply_filters('widget_title', $instance['title']); echo $before_widget.$before_title.$title.$after_title; if (empty($posts)) { echo '<div class="outspoken-error">'; if (is_admin_bar_showing()) { printf(__('No posts to show, please <a href="%s">add one</a>', 'outspoken'), admin_url('edit.php')); } else { _e('No posts to show', 'outspoken'); } echo '</div>'.$after_widget; return; } global $post; $show_categories = get_theme_mod('outspoken_home_categories'); for ($i = 0; $i < $limit; $i++): if (!isset($posts[$i])) break; $post = $posts[$i]; setup_postdata($post); $image = outspoken_post_image($post->ID, 'post-thumbnail'); ?> <article> <a href="<?php the_permalink(); ?>"><img src="<?php echo esc_url($image); ?>" alt="<?php the_title_attribute(); ?>" title="<?php the_title_attribute(); ?>" /></a> <div> <?php if ($show_categories): ?> <div class="meta-top"><?php outspoken_entry_categories(); ?></div> <?php endif; ?> <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> <?php $meta = outspoken_index_meta(false, false); if ($meta != ''): ?> <div class="meta"><?php echo $meta; ?></div> <?php endif; ?> <div class="summary"><?php the_excerpt(); ?></div> </div> </article> <?php endfor; wp_reset_postdata(); if (isset($posts[$limit])): ?> <div class="load-more"><span class="loader"></span><span class="text">Load More Posts</span></div> <script type="text/javascript"> jQuery(function() { var latest_entries_limit = <?php echo $limit; ?>; var latest_entries_offset = latest_entries_limit; jQuery('#<?php echo $args['widget_id']; ?>').on('click', '.load-more', function() { if (latest_entries_offset == 0) return; jQuery(this).addClass('active'); jQuery.ajax({ type: 'post', dataType: 'json', url: '<?php echo admin_url('admin-ajax.php?action=wpshower_latest_entries'); ?>', data: { limit: latest_entries_limit, offset: latest_entries_offset }, success: function(response) { for (var i = 0; i < response.posts.length; i++) { jQuery('#<?php echo $args['widget_id']; ?> .load-more').before( '<article>' + '<a href="' + response.posts[i].permalink + '"><img src="' + response.posts[i].image + '" alt="' + response.posts[i].title + '" title="' + response.posts[i].title + '" /></a>' + '<div>' + '<div class="meta-top">' + response.posts[i].categories + '</div>' + '<h2><a href="' + response.posts[i].permalink + '">' + response.posts[i].title + '</a></h2>' + '<div class="meta">' + response.posts[i].date + response.posts[i].comments + '</div>' + '<div class="summary">' + response.posts[i].excerpt + '</div>' + '</div>' + '</article>' ); } if (response.more) { latest_entries_offset += latest_entries_limit; jQuery('#<?php echo $args['widget_id']; ?> .load-more').removeClass('active'); } else { latest_entries_offset = 0; jQuery('#<?php echo $args['widget_id']; ?> .load-more').hide(); } if (scroll != false) scroll.loadMore(); } }); }); }); </script> <?php endif; echo $after_widget; } /** * Back-end widget form. * * @see WP_Widget::form() * * @param array $instance Previously saved values from database. */ public function form($instance) { if (isset($instance['title'])) $title = $instance['title']; else $title = __('Latest Entries', 'outspoken'); if (isset($instance['limit'])) $limit = $instance['limit']; else $limit = 4; ?> <p> <label for="<?php echo $this->get_field_name('title'); ?>"><?php _e('Title:', 'outspoken'); ?></label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /> </p> <p> <label for="<?php echo $this->get_field_name('limit'); ?>"><?php _e('How many items:', 'outspoken'); ?></label> <input class="widefat" id="<?php echo $this->get_field_id('limit'); ?>" name="<?php echo $this->get_field_name('limit'); ?>" type="text" value="<?php echo $limit; ?>" /> </p> <?php } /** * Sanitize widget form values as they are saved. * * @see WP_Widget::update() * * @param array $new_instance Values just sent to be saved. * @param array $old_instance Previously saved values from database. * * @return array Updated safe values to be saved. */ public function update($new_instance, $old_instance) { $instance = array(); $instance['title'] = !empty($new_instance['title']) ? strip_tags($new_instance['title']) : ''; $instance['limit'] = !empty($new_instance['limit']) ? intval($new_instance['limit']) : 4; return $instance; } }
-
I am a WP and PHP novice still flailing in the deep end of the pool. I am trying to add some logic to display content on certain pages (via WP templates), not on others. I've made some progress but having issues. Here is the plan: On certain pages with an post type of "EVENT" I want content to appear, but not on OTHER pages with an post type of "EVENT". The problem I am running into is that part of the content is appearing on ALL event pages even if they don't meet the criteria. The logic is intended to be this: If the page is post_type "EVENT", AND if the indicated table contains a field with a record CAT which matches the current "POST ID", AND contains a record TYPE which matches value "1", display table cells which contain text "Presented by: ", an href and an image, else display table cells which contain a nonbreaking space. The problem is that the text "Presented by: " is appearing on ALL the even pages, regardless of whether they meet the criteria or not -- which would tend to indicate a problem with the logic code -- but by the same token the href and image are correctly appearing ONLY on the pages that meet the criteria and are NOT appearing on along with the rogue text on pages which do not meet the criteria. I am sure it is a coding error on my part but I am not sure what. ANY help anyone could give would be GREATLY appreciated. The code involved is below (oh, and I should mention that the code in question is in the HEADER.PHP file): <?php if($post->post_type=='event') { $q1=mysql_query("SELECT * FROM table_name WHERE type = 1 AND cat = $post->ID "); $row_diamond=mysql_fetch_object($q1); if ($q1){ ?> <td width="115" align="right" valign="middle" id="diamond1"><strong style="position:relative;bottom:-25px;">Presented by: </strong></td> <td id="diamond2" width="190"> <a href="<?=$row_diamond->website?>" title="<?=$row_diamond->website_title?>" target="_blank" style="cursor:pointer;"><img style="position:relative;bottom:5px;" src="<?php bloginfo('siteurl'); ?>/wp-content/plugins/sean_event/files/<?=$row_diamond->image?>" alt="<?=$row_diamond->alt_text?>"border="0"></a> <br /> </td> <?php } else{ ?> <td width="115" align="right" valign="middle" id="diamond1"> </td> <td id="diamond2" width="190"> </td> <?php } } ?>
-
Working on a WordPress site. I've been again thrown into the deep end of the pool on this. I am trying to add some code to the HEADER.PHP file which will display content under certian conditions. Here's the code in question: $q1=mysql_query("SELECT * FROM 'wp_sean_sponsors' WHERE 'type' LIKE 1 AND 'cat'='.$post->ID.' "); $row_diamond=mysql_fetch_object($q1); if ($q1){ ?> The problem is that there doesn't seem to be anything coming back from the database. When I do a var_dump of $q1 it comes back as boolen(false), which I am taking to mean it has no value. But I know that a record which matches the criteria exists. I tried replacing '.$post->ID.' with a hard value with no change. I've got no clue where to go next but they're beating me until I come up with a solution.
-
where to link and how to link style.css in my custom page template in wordpress.plz reply
-
as i m newbee to wordpress can anyone tell me what i have to study or my task next. i have installed and upload wordpress i understand admin side and user side functionalite worked on dashboard understand folder structure and file structure of wordpress create a child theme of twenty.thirteen what's next move now
-
Hello, I've been working on my company site (Wordpress based) on XAMPP, which managed to get confused with the live site (my bad, I didn't update all the links). From the files I downloaded, I am no getting the following error when loading the site - I haven't changed anything in this file, so I'm baffled as to what has happened! line 137 is - $pinfos= get_group ('Page-Info',762); //print_r($pinfos); Any ideas?! I'm new to php, so finding this very trying!!! Many thanks