Affichage des articles dont le libellé est Plugin. Afficher tous les articles
Affichage des articles dont le libellé est Plugin. Afficher tous les articles

samedi 12 novembre 2016

Giveaway: Win a Free Copy of WPForms – WordPress Form Plugin



In the past, we have done several giveaways on WPBeginner and there’s been an overwhelming amount of requests from a lot of you to do more of them. Today, we’re proud to announce an amazing giveaway of our fast growing plugin, WPForms. This giveaway will allow 10 lucky users to win a Pro license of WPForms – drag & drop form builder (value 9).


Winners will be selected on Wednesday, July 6th, 2016.


**This giveaway has finished and is currently not available**


What exactly do you win? (WPForms Pro)


WPForms


10 lucky users will win the pro license of WPForms – the most user friendly WordPress form plugin.


The pro license is worth 9 each and comes with:


Drag & drop form builder, pre-made form templates, smart conditional logic, powerful notification system, entry management system, file uploads, multi-page forms, and all available addons (User registration, MailChimp, AWeber, PayPal, Stripe, GetResponse, Campaign Monitor, etc).


See the list of all features.


Whether you want to create a contact form, donation form, or a newsletter form, you can do it with WPForms.


How to Win?


In the past, we have had many winners who enter the contest and never claim the prize. This is unfair to all those who really wanted to win.


To mitigate that issue, we’re trying a new concept, so only those who’re serious about using the plugin will win.


To enter the giveaway, you need to:


1. Install the WPForms Lite Plugin on your site (100% free). (See how to install a WordPress plugin)


2. Inside, you will see a notice directing you to the Rafflecopter widget for entering the giveaway.


If you accidentally dismiss the notice, you can access it by going to this link:


**This giveaway has finished and the link is not available to use**


Simply replace yoursite.com with your own domain.


That’s all.


Winners will be selected on Wednesday, July 6th, 2016.


This new giveaway format will also allow you to try out WPForms to see why we believe it’s the most beginner friendly WordPress contact form plugin.


To learn more about WPForms, you can watch the overview video below:



All winners are chosen randomly using the Rafflecopter widget. We will notify the winners on July 6th, 2016 via email.


Thank you for following WPBeginner.


The post Giveaway: Win a Free Copy of WPForms – WordPress Form Plugin appeared first on WPBeginner.







How to Disable Plugin Updates in WordPress and Why You Shouldn’t



Recently, one of our readers asked if it was possible to disable plugin updates in WordPress? Plugin updates can be disabled in WordPress, but there is no good reason to do that. In this article, we will show you how to disable plugin updates in WordPress. We will also discuss why you shouldn’t do that and what could be the consequences of doing so.


How to Disable Plugin Updates in WordPress


Why You Shouldn’t Disable Plugin Updates in WordPress?


Many WordPress users think that plugin updates can break their site. If you are using the best WordPress plugins with a standard compliant WordPress theme, then chances of an upgrade breaking your site are very low.


See our beginner’s guide on how to choose the best WordPress plugins for your site. For themes, you may want to see our checklist of 9 things you should consider when selecting the perfect WordPress theme.


Plugin updates not only offer new features, they also patch security vulnerabilities, improve performance, and fix compatibility issues with latest or upcoming versions of WordPress.


By not updating plugins, you are intentionally compromising security and stability of your WordPress site.


Some developers want to disable plugin updates on clients sites to prevent them from breaking their websites. It is not a good reason in most cases because most client relationships don’t last forever. In that case you hand your clients a website susceptible to vulnerabilities in future.


We believe it’s simply better to educate your clients.


If you still must disable plugin updates on your site, then here is how you would do that.


Disable All Plugin Updates in WordPress


First thing you need to do is install and activate the Easy Updates Manager plugin. For more details, see our step by step guide on how to install a WordPress plugin.


Upon activation, you need to visit Dashboard » Update Options to manage plugin settings.


Click on the ‘General’ tab and scroll down to ‘All Plugin Updates’ option. Click on ‘Disabled’ to turn off all plugin updates.


Disable all plugin updates in WordPress


Don’t forget to click on the save changes button to store your settings.


Selectively Disable Updates for Specific Plugins in WordPress


You can also selectively disable updates for some WordPress plugins. This is a little better option than disabling all plugin updates.


You need to visit Dashboard » Update Options page and click on the ‘Plugins’ tab. There you will see a list of all installed plugins on your WordPress site.


Disallow updates for a specific plugin


You can just click on ‘Disallow Updates’ below a plugin to disable updates for that specific plugin.


Easy Updates Manager allows you to manage all WordPress updates including core, plugin, theme, and translation updates. See our guide on how to better manage automatic WordPress updates for detailed instructions.


We hope this article helped you learn how to disable plugin updates in WordPress and why you shouldn’t do that. You may also want to see our guide on how to hide unnecessary items from WordPress admin with Adminimize.


If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.


The post How to Disable Plugin Updates in WordPress and Why You Shouldn’t appeared first on WPBeginner.







WordPress Tutorial: How to Create a Testimonials Plugin



alt="WordPress Tutorial: How to Create a Testimonials Plugin" src="http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2013/06/wordpress-500x133_c.jpg" />

So, here we are for our second weekly tutorial on WordPress. We have learned how to create an href="http://www.webhostingsecretrevealed.net/blog/wordpress-blog/how-to-create-an-infinite-scrolling-wp-site/">infinite scrolling WP site and href="http://www.webhostingsecretrevealed.net/blog/inbound-marketing/wordpress-development-creating-an-awesome-page-flip-plugin/">page-flip plugin in the past. Today we’ll learn a little bit more about custom post types, and how to load their data.

This feature is really important in your site, since it allows you to show people recommending you. Testimonials are a great social proof of your awesomeness. And you don’t need complex plugins or a lot of code to achieve this, as you’ll see with a couple of files you can create a sexy presentation for your testimonials.

Let’s get started then!

Zip & Install

If you are in a hurry to check this, you can href="http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2013/06/testimonials.zip">download and install it.

You’ll need to add some data then, by adding a few testimonials using the brand new testimonials are you can see in your dashboard:

style="text-align: center;">class=" wp-image-1857 aligncenter border" title="Print Screen of Testimonial plugin" alt="list-testimonials" src="http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2013/06/list-testimonials.jpg" width="750" srcset="http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2013/06/list-testimonials.jpg 1133w, http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2013/06/list-testimonials-300x169.jpg 300w, http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2013/06/list-testimonials-750x424.jpg 750w" sizes="(max-width: 1133px) 100vw, 1133px" />

Then you can use the basic shortcode to load that:

[ testimonials rand=0 max=5 ]

When you’ve added that code you’ll see something like this in your page:

href="http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2013/06/main-testimonials.jpg">class="alignnone wp-image-1858 border" alt="main-testimonials" src="http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2013/06/main-testimonials.jpg" width="750" srcset="http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2013/06/main-testimonials.jpg 644w, http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2013/06/main-testimonials-300x142.jpg 300w" sizes="(max-width: 644px) 100vw, 644px" />

Now we’ll see how to create and explore this (by adding more functions and changing the look).

The Basics

As we’ve said before, you’ll need to add the title="WordPress Tutorial: How To Create An Awesome Page Flip Plugin" href="http://www.webrevenue.co/inbound-marketing/wordpress-development-creating-an-awesome-page-flip-plugin/">header metadata, create the plugin file and call your scripts. Long story short, you’ll create a new folder under your wp-content/plugins with your plugin’s name, then create a file with the same name as the folder to be your main plugin file.

Once you’ve done that copy and paste as follows:

<?php
/*
Plugin Name: Testimonials
Description: Display customer testimonials.
Version: 1.0
Author: Web Revenue Blog
License: GPL2
*/

//enqueueing scripts and styles
function plugin_scripts(){
    wp_enqueue_script('jquery');
    wp_enqueue_script('flexslider', plugins_url( 'js/jquery.flexslider-min.js' , __FILE__ ), array('jquery'), '2.2', false);
    wp_enqueue_script('testimonials', plugins_url( 'js/testimonials.js' , __FILE__ ), array('jquery'), '1.0', false);
    wp_enqueue_style('flexsliderCSS', plugins_url( 'css/flexslider.css' , __FILE__ ), false, '2.2', 'all' );
    wp_enqueue_style('testimonialsCSS', plugins_url( 'css/testimonials.css' , __FILE__ ), false, '1.0', 'all' );
}
add_action("wp_enqueue_scripts","plugin_scripts");

Here is what we’re doing:

  • Telling to the WP what’s our plugin’s name, author, what it does
  • Creating a function, where we insert regular scripts (like jQuery) and custom scripts (like flexslider), and Stylesheets
  • Telling to the WP to load the scripts function in its default scripts call, so they’ll be actually loaded in the pages

It’s all pretty cool, but don’t forget to actually create the files under /js and /css. You can just download them in our demo content so you don’t need to dig a lot to find the flexslider files.

Now we have all basic things in place we can start the funny part.

The Custom Post Type

By default, WordPress have 2 common post types, pages and posts. But it also has a lot of internal post types (like attachments), so the “post type” definition is: Every type of data you need to store.

As our plugin will create a new functionality WP doesn’t have a built-in place to store that, so we need to create that. Don’t be afraid little grasshopper, it’s quite simple, you can use this code:

//the black magic to create the post type
function create_post_type() {
    register_post_type(
        'testimonials',//new post type
        array(
            'labels' => array(
                'name' => __( 'Testimonials' ),
                'singular_name' => __( 'Testimonial' )
            ),
            'public' => true,/*Post type is intended for public use. This includes on the front end and in wp-admin. */
            'supports' => array('title','editor','thumbnail','custom_fields'),
            'hierarchical' => false
        )
    );    
}

Here we’re just using the register_post_type() function to tell to WP “Hey Buddy, we need to store this kind of data, please be ready to receive it”.

We also tell him that this kind of data is called “testimonials”, it should be available for public access (so it actually create a new menu item in your dashboard for it), the fields that we need on it, and if it’s hierarchical or not (like pages that we have parent and child pages).

Then we need to call it every time we load WordPress. This hook will do it:

add_action( 'init', 'create_post_type' );

The Custom Fields

Now our custom post type have the title (person’s name), the content (person’s testimonial), a picture (featured image) but it’s missing a link, since if the person is nice enough to talk about you, you should at least link to their site, right?

We could do this with usual custom fields, but it’s much better to have a “closed” field, where the user doesn’t need to type field’s name, and also where you can add some validation rules.

First of all we need to create a new metabox, which is those nice panels you have in your post edit area, each little panel is a metabox. This function will create and call it:

//adding the URL meta box field
function add_custom_metabox() {
    add_meta_box( 'custom-metabox', __( 'Link' ), 'url_custom_metabox', 'testimonials', 'side', 'low' );
}
add_action( 'admin_init', 'add_custom_metabox' );

The add_meta_box() function requires these parameters:

  1. ID – The unique identifier for it. You could use anything unique here like “unicorn-eating-rainbow” or “testimonial-link”. Anything that can be used internally
  2. Title – What will be shown for the user? Here it’s important to use the __() function, it’s the function that allow users from foreign languages to translate your plugin with .po files (without editing plugin files)
  3. Callback – The function where you have the actual contents of the metabox
  4. Post Type – In our case we want it to be visible only for testimonials
  5. Context – Where in the page you want to show it
  6. Priority – If it should be before other items of the same position or after them

Now we need to create the url_custom_metabox() function, since we’ve called it.

// HTML for the admin area
function url_custom_metabox() {
    global $post;
    $urllink = get_post_meta( $post->ID, 'urllink', true );

    //validating!
    if ( ! preg_match( "/http(s?):///", $urllink ) && $urllink != "") {
        $errors = "This URL isn't valid";
        $urllink = "http://";
    }

    // output invlid url message and add the http:// to the input field
    if( isset($errors) ) { echo $errors; }
?>    
<p>
    <label for="siteurl">URL:<br />
        <input id="siteurl" size="37" name="siteurl" value="<?php if( isset($urllink) ) { echo $urllink; } ?>" />
    </label>
</p>
<?php
}

Ok, now translating this to plain English:

  • The global variable $post is called, so we can know which is the POSTID of the current item
  • We load the current value for the URL
  • We validate If the value that user inserted is valid. If there is at least one “http” or “https” occurrence the value is OK, otherwise it’s in valid and we need to use the default value
  • Then we show the errors, if there’s any
  • Now we start the actual HTML, adding the default value in the input field as we’ve got in the PHP

After this point we need to actually save what’s being sent by the user. We’ll use the “save_post” hook, so every time WordPress saves a post it’ll call this function:

//saves custom field data
function save_custom_url( $post_id ) {
    global $post;    

    if( isset($_POST['siteurl']) ) {
        update_post_meta( $post->ID, 'urllink', $_POST['siteurl'] );
    }
}
add_action( 'save_post', 'save_custom_url' );

Here we just check if there’s any post data called “sitelink” which is our field name. If there is a sitelink, let’s save it.

After everything is in place, here is how your new testimonial  page will look like:

class="alignnone wp-image-1859 border" alt="new-testimonial" src="http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2013/06/new-testimonial.jpg" width="750" srcset="http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2013/06/new-testimonial.jpg 1133w, http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2013/06/new-testimonial-300x169.jpg 300w, http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2013/06/new-testimonial-750x424.jpg 750w" sizes="(max-width: 1133px) 100vw, 1133px" />

Loading our Custom Data

Now we need to actually load our items, and we’ll use the get_posts() function, mostly because we have only simple data so we don’t need a proper WP loop (that would add a lot of DB calls and we really don’t need it).

So, first let’s create a function to get our site’s link, if there’s any.

//return URL for a post
function get_url($post) {
    $urllink = get_post_meta( $post->ID, 'urllink', true );

    return $urllink;
}

Now, we can start the shortcode function.  A simple way to default and validate the shortcode data is creating the attributes for the loop as an array, so we can add new items as we need them, like this:

//registering the shortcode to show testimonials
function load_testimonials($a){

    $args = array(
        "post_type" => "testimonials"
    );

    if( isset( $a['rand'] ) && $a['rand'] == true ) {
        $args['orderby'] = 'rand';
    }
    if( isset( $a['max'] ) ) {
        $args['posts_per_page'] = (int) $a['max'];
    }
    //getting all testimonials
    $posts = get_posts($args);

    //HTML OUTPUT
}
add_shortcode("testimonials","load_testimonials");

As you can see we have the shortcode attributes loaded and passed to the $args array when they validate, in the format that WordPress needs it, so we can load posts using them.

Now we need to add some HTML code there, following flexslider’s default structure. Here is how it’ll look like:

echo '<div>';
    echo '<ul>';

    foreach($posts as $post){
        //getting thumb image
        $url_thumb = wp_get_attachment_thumb_url(get_post_thumbnail_id($post->ID));
        $link = get_url($post);
        echo '<li>';
            if ( ! empty( $url_thumb ) ) { echo '<img src="'.$url_thumb.'" />'; }
            echo '<h2>'.$post->post_title.'</h2>';
            if ( ! empty( $post->post_content ) ) { echo '<p>'.$post->post_content.'<br />'; }
            if ( ! empty( $link ) ) { echo '<a href="'.$link.'">Visit Site</a></p>'; }
        echo '</li>';
    }

    echo '</ul>';
echo '</div>';

Wait, but why would we create the HTML code inside of the PHP function? That’s because we can conditionally load content only if the user have added content, so you won’t have empty HTML tags, just waiting to mess up your layout.

What about the sidebar?

Most people just want to show testimonials in the sidebar, and this plugin won’t work really well since text widgets don’t process shortcodes. There’s a simple solution for this, just add this in your code:

add_filter('widget_text', 'do_shortcode');

What’s next?

So, did you enjoy this tutorial? What would you add as an option for your testimonial shortcode? Do you have any ideas for future posts? Let us know using the comments section!


Page 18 – Web Hosting Secret Revealed




WordPress Tutorial: How To Create An Awesome Page Flip Plugin



alt="WordPress Tutorial: How To Create An Awesome Page Flip Plugin" src="http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2013/06/0611-3-500x402_c.jpg" />

Note: We no longer support this WP plugin as the author is not writing for us for now. 

Starting today, every week we’ll feature an awesome coding tutorial, teaching you how to do custom stuff using WordPress, from basic to advanced. Today we’ll create a plugin (so you’ll learn the basic steps on this) to generate a “page flip” gallery, using JS.

I bet you’ve seen one of those in your early web days, but those were mostly done using flash, which now is quite of deprecated (it still has its value, but it’s not the best option for this kind of thing anymore).

The basic functionality will be create a new href="http://www.turnjs.com/#samples/html5">type of gallery based on a few images and their sizes, via shortcode.

Let’s get started then!

Zip & Install

The best way to see it in action is installing it yourself. You can href="http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2013/06/flipbook-gallery.zip">download it here. Install and activate the plugin, then all you need to do is to add the shortcode in a page, like this:

[flip_book ids = "78 79 78 79 79 78 78 79 79 78" width="300" height="225" display="double"]

Quick Preview

And this is the kind of result that you’ll get:

class="aligncenter size-full wp-image-1731" src="http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2013/06/0611-2.jpg" alt="Flipbook Effect " width="600" height="223" srcset="http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2013/06/0611-2.jpg 600w, http://whsr.webrevenueinc1.netdna-cdn.com/wp-content/uploads/2013/06/0611-2-300x111.jpg 300w" sizes="(max-width: 600px) 100vw, 600px" />

But what sort of black magic goes on there? Well, it’s quite simple actually. Let’s learn how to create something like this.

The Header

First of all you’ll need to create a new folder and a new .php file. At this point it would be awesome if you have a test environment, so you can break and test stuff.

The file and folder should have a simple and unique name, so you’ll avoid conflict with existing plugins. Then the basic content of our file is something like this:

/*
    Plugin Name: FlipBook Gallery
    Description: Create a shortcode for flipbook galleries.
    Version: 1.0
    Author: Web Revenue Blog
    License: GPL2
*/

Pretty simple, huh? Once you create this file you’ll see your plugin in the list under WP admin > Plugins, and you can activate it (but if you only have this content in your file it won’t change a lot your site).

Calling scripts

Now we need to include some important external assets here. The required external files for basic functionality are:

  • jQuery (1.9+)
  • Turn.js script
  • Turn basic styling

If you simply add the script and style tags there you’ll have some issues. For instance, the double jQuery call will probably break your site. Also WordPress itself won’t “know” that you’ve created those items, so if a different plugin calls turn.js again or a different styling it’ll break your site.

That’s why we should always use the wp_enqueue_script and wp_enqueue_style functions. Here is the basic usage:

function plugin_scripts( ) {
    wp_enqueue_script('jquery');
    wp_enqueue_script('turn', plugins_url( 'js/turn.js' , __FILE__ ), array('jquery'), '1.3', false);
    wp_enqueue_style('turnCSS', plugins_url( 'css/style.css' , __FILE__ ), false, '1.3', 'all' );
}

We are calling external items in 3 different ways, here they are:

  • Calling an existing item: jQuery – We don’t need to pass a lot of parameters if we know for sure that WordPress already load this script, we’re just telling him “Dude, this script MUST be here otherwise our code won’t work”
  • Creating a new script – you’ll need to pass some attributes like name, file location, required items (in this case it requires jQuery), version, and if it’s loaded in the footer or header (false = header, true = footer)
  • Creating a new style – Pretty much the same as the previous one, with a small difference in the last attribute, that says which media type this style if for

One of the important things you should consider when you’re calling external scripts is if there is more code that will depend on this plugin. That is basically what defines if your file will be called in the header or footer.

In our case, we have some additional scripts to set up the gallery only when its HTML is created, and that will be added in the body. This is why we MUST add this script in the head, otherwise when our code is called the “turn” function is not there yet.

After this nice code we need to tell WordPress to load those as scripts, the action “wp_enqueue_scripts” will do this:

add_action('wp_enqueue_scripts', 'plugin_scripts');

The Shortcode

Let’s start with the action to create the shortcode. It’s quite simple, you just need to add the shortcode trigger, and the function that will be executed:

add_shortcode("flip_book","create_flip_book");

Now we need to create our function and get our attributes. But some of the attributes can be optional, which means that we’ll need to create default values for them. We could create a lot of if’s there testing if the attribute is empty, but this is one of the cases where ternary operation is better than the regular if call.

Ternary operations are kind of if statements directly in variable’s value. If follows this structure:

$variable = ( CONDITION ) ? "VALUE IF CONDITION IS TRUE" : "VALUE IF CONDITION IS FALSE";

You can see them in action in the first part of our function:

function create_flip_book( $attr ) {

    //Preparing the IDs to be processed
    $array['ids'] = explode(" ",$attr['ids']);

    //display mode
    $array['display'] = empty( $attr['display'] ) ? "single" : $attr['display'];//standard value

    //width
    $array['width'] = empty( $attr['width'] ) ? 400 : $attr['width'];

    //height
    $array['height'] = empty( $attr['height'] ) ? 300 : $attr['height'];
    //HTML and the rest of the code goes here
}

Then we’ll need to create the HTML, and the basic call for our images. Another important point here is to adjust the size if we’re using magazine style (it should be 2x the width since we’ll have 2 images instead of one):

<?php
    if ( $array['display'] == "double" ) {
        $array['width'] = $array['width'] * 2;
    }
    // HTML, JS and Black Magic
?>
<div id="flipbook">
    <?php
        for( $i = 0; $i < sizeof( $array['ids'] ); $i++ ) {
    ?>
        <div>
            <?php
                echo wp_get_attachment_image( $array['ids'][$i], 'full' );
                if( $array['display'] == "single" ) {
            ?>
                <span><?="".($i+1)?>/<? echo "".sizeof($array['ids'])?></span>
            <?php
                } else {
            ?>
                <spanright" : "left");
                ?>">
                <?php
                    echo "".($i+1)?>/<? echo "".sizeof($array['ids']);
                ?>
                </span>
            <?php
                }
            ?>
        </div>
    <?php
        }
    ?>
</div>
<script type="text/javascript">
    jQuery("#flipbook").turn({
        width: <?php echo $array['width']; ?>,
        height: <?php echo $array['height']; ?>,
        autoCenter: true,
        display: '<?php echo $array['display']; ?>',//single page or double page
        acceleration: true,
        gradients: ! jQuery.isTouch,
    });
</script>

What do you think?

Now you can tweak and modify this as you want, adding more options (check out their awesome examples for more inspiration), adjusting what doesn’t work for you, or combining this with other plugins.

Do you have any WordPress concept you want to learn a little bit more? Maybe something you want to learn how to do? Let us know via comments and we’ll be glad to include this in a future post!


Page 20 – Web Hosting Secret Revealed