Loading...

Follow WP Garage - WordPress tricks, hacks, and tips on Feedspot

Continue with Google
Continue with Facebook
or

Valid

Many of our clients offer whitepaper PDFs on their site to generate leads. Therefore, our clients don’t want people to find their whitepaper PDFs from a Google search. Rather, they want to get people’s email address first before giving access to their whitepaper.

The easiest way to hide a PDF uploaded to WordPress from search engines, or to noindex it, is to do the following:

  1. Install and activate the Yoast WordPress SEO plugin
  2.  Upload the PDF to the media library
  3. Edit the PDF in the media library. Depending on how your media library looks (tile view or list view) here’s how to find the Edit link:
    In grid view, click on the PDF and then click Edit More Details:
    In list view, click Edit on the PDF:
  4. In the Yoast SEO settings for the media item, click the gear icon. Set the “Meta robots index” to noindex. This will make sure the file (not just the media attachment page) is not indexed by search engines. Ideally, you should modify this setting when you upload a new PDF. If the PDF already exists, it is probably already indexed in Google and might take some time for search engines to recrawl your site to noindex it.

This post was originally published at How to hide (noindex) a PDF in WordPress from search engines on WP Garage - WP Garage - WordPress tricks, hacks, and tips.

Read Full Article
Visit website
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Our client sells a product for smartphones. Therefore, customers need to first select the brand of their phone, eg. Apple or Samsung. And then they need to select the phone model, eg. iPhone 7 or Galaxy s8, respectively.

Attribute setup

Here’s our attributes setup in our WooCommerce product:

Variations setup

Here’s our variations setup in our WooCommerce product:

Frontend select dropdown menus

Here’s how our product dropdown select menus look in the frontend

First, you select a phone brand:

Then you select a phone model, depending on which phone brand you choose:

But what happens if you go back and want to select Samsung instead? Ack! Where did Samsung go?

The problem

The problem was that if you select Apple from the first dropdown menu and then iPhone 7 from the second menu, and then if you want to change your first selection to Samsung, you can’t! After you choose Apple, Samsung disappears from the first dropdown menu!

The reason that some options in the first dropdown disappear is logical for most use cases, but not for ours. The logic is as follows: if Apple (from the first menu) and iPhone7 (from the second menu) are selected, then that’s a valid combination. However, if I want to go back and change my Apple selection to Samsung, I’m basically selecting a non-existent combination of Samsung and iphone7. Therefore, WooCommerce “locks” in only real variation combinations and hides the others.

Therefore, we need to “unlock” the combination logic so that a user can go back and change their original selection without using a “clear” button. We want the user to be able to go back and change their selection from Apple to Samsung in the first menu and then the secondary menu should display “Choose an Option” (instead of the previously selected phone model eg iphone 7) so the user can select a Samsung model.

The solution

We found a discussion about locked combinations for WooCommerce product variations and used the code from Variations UX as the foundation to the solution created by illuminea‘s developer, Alon Katziri.

Here are the steps we followed to “unlock” the product variations.

  1. Put this code in your functions.php to allow WooCommerce selection to use “non-locking” combinations.

remove_action( 'woocommerce_variable_add_to_cart', 'woocommerce_variable_add_to_cart', 30 ); 

// define the woocommerce_variable_add_to_cart callback 
function action_woocommerce_variable_add_to_cart( $woocommerce_variable_add_to_cart ) { 
    global $product;
        // Enqueue variation scripts
        wp_enqueue_script( 'wc-add-to-cart-variation' );
        // Get Available variations?
        $get_variations = sizeof( $product->get_children() ) <= apply_filters( 'woocommerce_ajax_variation_threshold', 30, $product );
        // Load the template
        wc_get_template( 'single-product/add-to-cart/variable.php', array(
            'available_variations' => $get_variations ? $product->get_available_variations() : false,
            'attributes'           => $product->get_variation_attributes(),
            'selected_attributes'  => $product->get_default_attributes(),
            /*
             * Selection UX:
             * - 'locking':     Attribute selections in the n-th attribute are constrained by selections in all atributes other than n.
             * - 'non-locking': Attribute selections in the n-th attribute are constrained by selections in all atributes before n.
             */
            'selection_ux'         => apply_filters( 'woocommerce_variation_attributes_selection_ux', '<strong>non-locking</strong>', $product )
        ) );
}; 
         
// add the action 
add_action( 'woocommerce_variable_add_to_cart', 'action_woocommerce_variable_add_to_cart', 10, 2 );

2. Add this code to your functions.php as well. This code overrides the WooCommerce javascript with your own javascript file so that you can tweak the variation ‘locking’ functionality in WooCommerce.

function wc_deregister_javascript() 
{
    wp_deregister_script( 'wc-add-to-cart-variation' );
    wp_register_script( 'wc-add-to-cart-variation', get_bloginfo( 'stylesheet_directory' ). '/js/wc-add-to-cart-variation.js' , array( 'jquery','wp-util' ), false, true );
    wp_enqueue_script('wc-add-to-cart-variation');
}
add_action( 'wp_print_scripts', 'wc_deregister_javascript', 100 );

3. Create a file in your theme called “wc-add-to-cart-variations.js” with the following file structure:  /your-theme/js/wc-add-to-cart-variation.js

4. Copy this code and paste it into the wc-add-to-cart-variations.js file. If you delve into this code, look for the selection_ux filter to see the locking / non-locking functionality.

5. In your theme’s WooCommerce template files,  create a file your-theme/woocommerce/single-product/add-to-cart/variable.php, and copy the template file from the plugin, and then replace the form code with this code:

<form  method="post" enctype='multipart/form-data' data-product_id="<?php echo absint( $product->get_id() ); ?>" data-product_variations="<?php echo htmlspecialchars( wp_json_encode( $available_variations ) ) ?>" data-selection_ux="<?php echo $selection_ux; ?>">
  <?php do_action( 'woocommerce_before_variations_form' ); ?>

Now people can go back and make a different selection!

This post was originally published at How to unlock variation combinations in WooCommerce dropdowns on WP Garage - WP Garage - WordPress tricks, hacks, and tips.

Read Full Article
Visit website
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

If you absolutely must use Placeholders in your forms, even though it’s really not good for accessibility, in particular for users with visual impairments, then here’s how to do it with Gravity Forms, our form builder of choice.

Step 1: Add this php code to your functions.php file:

add_filter( ‘gform_enable_field_label_visibility_settings’, ‘__return_true’ );

Step 2: In Gravity Forms, click on the Appearance tab for your field.
Fill out the Placeholder and set “field label visibility” to “hidden”.
Here’s a screenshot:

Here’s a screenshot of how our form looks in the front-end.

This post was originally published at How to Use Placeholders (not good for accessibility) in Gravity Forms on WP Garage - WP Garage - WordPress tricks, hacks, and tips.

Read Full Article
Visit website
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

I am currently using version 5.4 of the Jetpack plugin and I couldn’t for the life of me figure out where to activate my favorite modules in Jetpack which are:

  • Monitor: Jetpack Monitor will keep tabs on your site, and alert you the moment that downtime is detected.
  • Tiled Galleries: for beautiful photo galleries

On the Settings page, under Security here’s what I see:

I don’t see anything about Monitor.

Only after I wrote to their support team, did I find the magic door that leads to all the modules.

On the bottom of the Jetpack Settings page, there is a magical Debug link.

Click the Debug link.

On the Debug page, look for the link “Access the full list of Jetpack modules available on your site.

You’ve made it! Now you can see a normal list of all the modules. Yay!

This post was originally published at How to find Jetpack’s hidden modules on WP Garage - WP Garage - WordPress tricks, hacks, and tips.

Read Full Article
Visit website
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

As much as I love me my Gravity Forms, setting up the notifications can be really time consuming and not so straightforward!

We have a site that has a donation form where people can donate one-time, monthly, or yearly.

I assumed that if you have a notification for “Payment Completed” that you would get a notification about all donations.

But you won’t! You need to set up two notifications.

  1. The first notification is upon the event “payment completed”. This is for one-time payments.
    You don’t need to set up conditional logic for this form since it only sends a notification for one-time payments.
  2. An additional notification for “Subscription Created’ to get a notification that someone made a recurring donation.

In that notification, you’ll need to create conditional logic so that if the recurring donation is monthly or yearly, you’ll get a notification.

You can also get additional notifications such as every time there is a new payment made in a subscription.

You can see the full list of notification events here.

This post was originally published at Gravity Forms: recurring payments require a separate notification on WP Garage - WP Garage - WordPress tricks, hacks, and tips.

Read Full Article
Visit website
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

After updating WooCommerce to 3.0, clicking the Add to Cart button on a grouped product page led to an error page in Chrome that said:

This page isn’t working

Chrome detected unusual code on this page and blocked it to protect your personal information (for example, passwords, phone numbers, and credit cards).
Try visiting the site’s homepage.
ERR_BLOCKED_BY_XSS_AUDITOR

Here’s a screenshot:

First, I looked through all the template files that needed updating by going to: WooCommerce > System Status > Templates and saw that the file woocommerce/single-product/add-to-cart/grouped.php was out of date (along with many others).

I replaced the grouped.php file with the latest WooCommerce version of that file and the site started working properly again.

There really should be a better way of customizing WooCommerce files so that you don’t need to worry about a site breaking every time you update the plugin!

This post was originally published at Chrome error: ERR_BLOCKED_BY_XSS_AUDITOR after updating WooCommerce 3.0 on WP Garage - WP Garage - WordPress tricks, hacks, and tips.

Read Full Article
Visit website
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

A while back, some of our clients asked how they can best present a PDF on their website other than just a link. So we searched for a WordPress plugin that would embed a PDF into a post or a page, but couldn’t find one that was clean-coded and lightweight…so we built our own: Simple Google Docs Viewer

The plugin is easy to use, and you can embed a doc in a WordPress post or page with a simple shortcode. Here’s an example of how a PDF looks when embedded onto a post with the plugin:

Depending on the size of your file, it might take a few seconds for the PDF to appear.

Unfortunately, after publishing the plugin we kind of ignored it for a few years, and only recently realized that it didn’t support sites running with ssl that have https in their URL. Worry not, it is now updated and you can use it on your http and https sites, and it is also now responsive!

You can check out the Simple Google Docs Viewer plugin in the WordPress plugin repository.

This post was originally published at Easily embed PDFs, Word, and PPT in your WordPress website with Simple Google Docs Viewer plugin on WP Garage - WP Garage - WordPress tricks, hacks, and tips.

Read Full Article
Visit website
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Over the weekend, WordPress co-creator Matt Mullenweg called out Wix for using some of WordPress’ Open Source, GPL-licensed code in an improper fashion in their new mobile app; and also for ripping off the WordPress brand by calling Wix “WixPress.”

Here’s Wix CEO Avishai Abrahami’s response, and here’s why it’s problematic:

Wix should have provided GPL attribution

Matt said Wix should have provided proper attribution to WordPress for the code used in the mobile app. Abrahami does not address this. Yes, Wix has released over 200 Open Source projects on Github, but doing a good thing doesn’t reconcile doing a not-good thing. If the license says they need to provide attribution, they should address that specific issue for this specific piece of software.

GPL means public release of software

Matt states that if a piece of software includes any components from other GPL software, that makes the whole new piece of software GPL and it should therefore be made public if distributed (which the mobile app was). This is indeed the case, and it is not addressed in Abrahami’s response. Releasing partial components on Github is not enough.

Wix WAS called Wixpress in the past

Matt refers to Wix having ripped off WordPress’ brand by calling themselves Wixpress. I did a quick Google search for “Wixpress Ltd.” and lo and behold, Wix started out as Wixpress. Press releases were filed under the Wixpress name, and the official company name listed in the filing on  the stock exchange is Wixpress Ltd. It is noted in the document that they changed their business name in the US (and after checking the Israeli business registry, it was also changed here), and are now called Wix.com Ltd. Their Brazilian subsidiary is still referred to as Wixpress in the filing. None of us know them as Wixpress, so they seem to have smartly shifted away from that brand early on. In fact, while they initially filed for a trademark for this name, they abandoned it in 2010 which indicates they weren’t invested in that name. But the bottom line is, Wixpress is part of their legacy. Why did Abrahami deny that when we all know how to use Google? A more straightforward response would have been “Yeah, in the beginning we made a mistake with our brand, and if you ask anyone what Wixpress is, they probably won’t know since we abandoned that early on in favor of Wix.com”

The tone of Wix’s response is…unsettling

There’s something about Abrahami’s tone in his email that irks me.

Maybe it’s how he calls Matt “dude” and says “I didn’t know we were fighting”. You’re not fighting so don’t make it into a fight: Matt wants you to do what he thinks is right.

Maybe it’s how he tries to deflect accusations of brand-stealing by saying that WordPress has shifted from being only about blogs to being about websites too – I mean, what? Is he saying that Wix has sole ownership of the website-building space and Automattic stole that from them? A company is allowed to expand its focus for goodness sake.

Maybe it’s how he invites Matt to coffee, which is a poor reading of a serious situation. If you think someone ripped off your stuff, you may not feel like getting together with them for coffee…probably more like a court of law.

Also, why didn’t he link to Matt’s original post?! That’s a rhetorical question, but it looks shady. I think it would have been better for the company to have publicized the response by the engineer responsible for the mobile app that Abrahami links to in his post. It addresses the issues in a less…um…passive-aggressive dude-filled way and he shows how he tried to collaborate and share with Automattic’s engineering team. It still doesn’t provide satisfactory answers to the issues at hand, but it’s easier to digest.

Bottom line: lessons to be learned
  1. If you are a commercial company, think a bajillion times before using Open Source code in your proprietary software. Licensing is not only an ethical issue, but can also cause problems down the line if unreported and discovered during due diligence. Here’s a good article on this subject:
    https://twitter.com/stratticweb/status/790832690287087616. It also seems that the Apple Store does not allow GPL code-based apps since the app store’s protections negate the GPL license. So yikes.
  2. Don’t respond to issues immediately, and especially not over the weekend. Matt posted on Friday, and Abrahami posted on Saturday. People are taking a break over the weekend, there’s no rush! It seems that Abrahami wrote in the heat of the moment. He probably should have first had his legal team review the situation, and if necessary, apologize, remove the app from the app store, remove the GPL code and re-release it; OR keep the GPL code, add attribution, and publicly distribute it. In general, your legal/PR/marketing team isn’t working at full capacity on Saturday/Shabbat, so wait until they get to work, review the issues calmly, and then respond. No one’s going anywhere.
  3. Make sure you have people on your team who understand the nuances of other cultures. What’s interesting is that many of my Israeli Facebook hi-tech friends are commending Abrahami on his post. As a grew-up-in-Canada person, I’m cringing when I read it, and I’m not the only one. If you are a non-American company, make sure you have an Anglo on your PR team who has a better grasp of what kinds of tones and intonations work well outside of Israel. We Israelis have a very direct way of communicating, and while that can be great at times, it’s definitely not always great.

Look, Matt’s approach to GPL can come across as zealous. And the GPL has never been tried in an American court of law, so it’s not clear that Matt is right about everything in this case (or other cases). And it’s also possible that Wix made an innocent mistake. Open Source licensing can be confusing and unclear. I’m sure there’s a way to resolve this quickly and painlessly. In the future though, all hi-tech companies should strive to increase awareness of what Open Source means, have decent legal counsel, and a good PR team that reacts thoughtfully to branding and legal crises.

This post was originally published at Why Wix’s response to WordPress re GPL license is weak on WP Garage - WP Garage - WordPress tricks, hacks, and tips.

Read Full Article
Visit website
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Our love for Gravity Forms(aff) continues. Yes it costs money. And yes, its worth it. This time it’s because of how we integrated Gravity Forms with Salesforce.

Goal: Capture leads from the website, including the Adwords and Google Analytics parameters, and pass them to Salesforce.

Plugins  you’ll need:

  1. Install Gravity Forms.
  2. Install the Gravity Forms for Salesforce Addon Plugin. This is not an official Gravity Forms plugin, and doesn’t have much support, and isn’t actively updated, but… it works, at least for now.
  3. Install the Gravity Forms Prepopulate plugin. Also, not an official Gravity Forms plugin, but it’s so simple and works beautifully.

Step 1: Company field is required by Salesforce

Salesforce requires the company field but we didn’t want our form to require it so we used this code in functions.php:

<?php add_action( 'gform_pre_submission', 'pre_submission_handler' );
function pre_submission_handler( $form ) {
if ( ! rgpost( 'input_3' ) ) {
$_POST['input_3'] = 'Company Not Filled Out';
}
}

Step 2: Create hidden fields in Gravity Forms to capture the Google Adwords (GCLID) and Google Analytics (utm_campaign, etc) parameters 

Create hidden fields in Gravity Forms for each parameter you need, such as: utm_source,utm_campaign,utm_medium,utm_term,utm_content, and gclid.

Click on the Advanced tab, and check the box for “Allow field to be populated dynamically”.
Add the parameter name.

Step 3: Save parameter values in a cookie so they can be passed to Salesforce

The hidden field works great if someone goes to a direct link with all the parameters and fills in a form.
Ex.
http://test.com/?utm_source=testcampaign&utm_medium=testmedium&utm_term=testterm&utm_content=testcontent&utm_campaign=testcampaign

But if a user goes to another page on the site and then comes back and fills in the form, then we’ve lost all the data.

Therefore, we need to save the parameters with a cookie. That’s where the fabulous Gravity Forms Populate plugin comes into play. Go to the plugin settings and enter the parameters.

Step 4: Pass lead info to Salesforce

Now that we have all the info to send, we need to set up the Salesforce plugin and pass the lead info to Salesforce.

Make sure to use the API and not the Web to Lead. Web to Lead didn’t work with custom fields.

Connect the plugin to your Salesforce Account

Go to Forms > Salesforce and click Add New

Select what Object you want to use. We used Lead.
Select the form to integrate with.

Map your form fields to your Salesforce fields

Step 4: Test all the things

You can use the Google link builder to get a test url with all the parameters. (You can learn more about the link builder here)

Click on the test url (ex. http://test.com/?utm_source=testcampaign&utm_medium=testmedium&utm_term=testterm&utm_content=testcontent&utm_campaign=testcampaign)

See if your parameter values are getting stored in a cookie with the Resources tab in the Chrome console

Fill out the form and check in Salesforce to see if the info is there!

Good luck!

This post was originally published at Integrating Gravity Forms with Salesforce and saving parameters from Google Analytics and Adwords on WP Garage - WP Garage - WordPress tricks, hacks, and tips.

Read Full Article
Visit website
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Separate tags by commas
To access this feature, please upgrade your account.
Start your free month
Free Preview