A WordPress site without plugins… Is this possible? [Quick Guide]

9:40 pm February 1, 20178690

Who doesn’t love the plugins offered on the official directory of WordPress, or even via an external platform? Nobody, of course! Plugins are ubiquitous and even essential for those who are not developers in the soul, but they also can significantly slow down your site or blog if you collect them in a frenetic manner…

A WordPress without any plugin? NO! but do you know that you can easily replace the presence of some plugins by a few lines of code? We will see together how to do without certain plugins become a little too intrusive.

Un WordPress sans plugins ?

What interests to remove plugins to let place to code internally? 
It is certainly the question that you should ask yourself! Why bother? Here are the top reasons:

  • not be dependent on a third person/platform/developer
  • out of the box and get a totally customized module
  • automate and save time if you regularly create sites in WordPress (via a child theme customized or even your own template)
  • reduce the time to load due to the many requests made to loader some plugins (CSS Javascript etc…)
  • fix the incompatibilities easily because it is you who have coded it, as a result, you will quickly find the solution!
  • no longer waste time to install and configure some plugins

What plugins can easily happen?

The list could be very long, but I propose you to discover a selection of features that are typically used by a large number of WordPress sites, starting with:

1. Sharing without plugin buttons

there are many plugins “social sharing” , some are simple, others are real gas plants and some are really interesting … The concern is that they usually use Javascript and generate many requests for each social network. The result, they can reduce the performance of your site!

The solution? Add code in the file functions.php of your child theme , stylize the appearance of your buttons with a bit of CSS (to be placed in the file style.css to your child theme) and voila! Farewell Share This, Shareaholic, Digg Digg etc… If you want to try for yourself, use the code available below and feel free to make changes so that it adapts to your project.

See the code for the file functions.php

 / * sharing buttons without plugins * / function my_sharing_buttons ($content) {global $post;
 If (is_singular (): is_home()) {/ / get the current $myCurrentURL page URL = urlencode (get_permalink ());}
 
 Get the current $myCurrentTitle page title = str_replace (' ', '% 20', get_the_title());
 
 Retrieve thumbnail to Pinterest $myCurrentThumbnail = wp_get_attachment_image_src (get_post_thumbnail_id ($post-> ID), 'full');
 
 Construction of the URLs for sharing $twitterURL = 'https://twitter.com/intent/tweet?text='. $myCurrentTitle.' & url ='. $myCurrentURL.' & via = LaWebeuse';
 $facebookURL = 'https://www.facebook.com/sharer/sharer.php?u='. $myCurrentURL;
 $googleURL = 'https://plus.google.com/share?url='. $myCurrentURL;
 $linkedInURL = 'https://www.linkedin.com/shareArticle?mini=true&url='. $myCurrentURL.' & title ='. $myCurrentTitle;
 $pinterestURL = 'https://pinterest.com/pin/create/button/?url='. $myCurrentURL.' & media ='. $myCurrentThumbnail [0].' & description ='. $myCurrentTitle;
 $emailSHARE = ' mailto:?subject=Regarde this article! & BODY = Hey! I wanted to share with you this interesting article: '. $myCurrentURL.' & title ='. $myCurrentTitle;
 
 Adding the button at the bottom of articles and pages $content. = '
'; $content. = '
share now!
'; $content. = ' Twitter '; $content. = ' Facebook '; $content. = ' + '; $content. = ' LinkedIn '; $content. = ' pin It '; $content. = ' eMail '; $content. = '
'; return $content; } else {/ / if it is not an article or a page, do not include buttons shares return $content;} } }; add_filter ('the_content', 'my_sharing_buttons');

See the code for the file style.css

 / * customize the sharing buttons * / .msb-link {padding: 5px 15px 5px 15px! important;}
 color: white;
 do-size: 12px;
 border-radius: 2px;
 margin-right: 2px;
 cursor: point;
 box-shadow: inset 0 - 3px 0 rgba (0,0,0,.2);
 -moz-box-shadow: inset 0 - 3px 0 rgba (0,0,0,.2);
 -webkit-box-shadow: inset 0 - 3px 0 rgba (0,0,0,.2);
 margin-top: 2px;
 display: inline-block;
 text-decoration: none;
 {text-transform: uppercase} .msb - link:hover, .msb-link: active {background: #ff942a;}
 transition: all 0.3 s ease-in;
} .msb-twitter {background: #00aced;}
 
.MSB-facebook {background: #3B 5997;}
 
.MSB-googleplus {background: #D64937;}
 
.MSB-pinterest {background: #bd081c;}
 
.MSB-linkedin {background: #0074A 1;}

.MSB-email {background: #878787;}
 
social-networking-.sharing {margin: 20px 25px 0px 0px;}
 do-size: 12px;
} * CUSTOMIZE the buttons of shares for RESPONSIVE * / @media only screen and (max-width: 680px) {/ * put your Responsive CSS here * /} 

here is the result:

2. Create a “Related Post” section without plugin

you certainly know the “Related Post” or “Related Articles” section at the end of a post, which displays a number of articles to read… This is a very important feature in a blog term of SEO and also because it allows the reader to easily find other articles that relate to a category or a keyword, and finally helps to maintain this visitor yet a few more minutes on your site! There are only benefits to implement!

According to the WordPress theme you are using, the “related post” section can you be offered as an option, otherwise you’ll have to use a plugin… or not! And if you decide to include this feature at the end of your articles yourself, here is the procedure:

  1. duplicate the file single.php to your parent theme: this is the file that handles the template for your items. As a result, the “related post” section will appear only at the end of your articles and not on your pages or on your custom post types.
  2. Open the single.php with a text editor and add the code below in the loop main , just above comments: this is usually the place to view this section.
  3. Send the file in your child theme via FTP (if already present on your server).
  4. Stylize the appearance of the elements of this section adding of CSS in the file style.css to your child theme, to make it attractive. You can use the code below for example.

See the code for the file single.php

 / * SECTION RELATED POST without plugins * / 

you may also like:

ID); call posts by category, if by tags use: $tags = wp_get_post_tags ($post-> ID); If ($categories) {/ / if by tags: if ($tags) {$category_ids = array(); / / if by tags: $tag_ids = array();}} foreach ($categories as $individual_category) $category_ids [] = $individual_category-> term_id; If by tags: foreach ($tags as $individual_tag) $tag_ids [] = $individual_tag-> term_id; $args = array ('category__in' => $category_ids, / / if by tags: 'tag__in' => $tag_ids, 'post__not_in'-online array ($post-> ID), 'posts_per_page'-online 3, / / number of posts to display 'caller_get_posts'-online 1); $my_query = new wp_query ($args); While ($my_query-> have_posts()) {$my_query-> the_post(); ? >

see the code for the file style.css

 / * section you AIMEREZ also - related post * / change-related-post {width: 100%;} 
 margin: 20px 0 20px 0; 
 padding: 20px;
 float: left; 
 do-size: 16px;
 box-shadow: 0 1px 3px 0 rgba (0,0,0,.1);
} hickiing-related-post h3 {make-size: 22px;} 
 margin-bottom: 10px; 
} .each-post {float: left;} 
 width: 30%;
 margin-right: 5%;
} .each - post:last - child {margin-right: 0%;}

.every-post img {margin: 0 3px 0 0;} 
 width: 100%;
 padding: 0;
 background - position: center;
 transition: all 0.5s ease;
 -moz-transition: all 0.5s ease;
 -ms-transition: all 0.5s ease;
 -webkit-transition: all 0.5s ease;
 -o - transition: all 0.5s ease;
} .each-post img:hover {transform: scale (1.1);
 -moz-transform: scale (1.1);
 -webkit-transform: scale (1.1);
 -o - transform: scale (1.1);
 -ms-transform: scale (1.1); * IE 9 * /-ms-filter: "progid:DXImageTransform.Microsoft.Matrix (M11 = 1.5, M12 = 0, M21 = 0, M22 = 1.5, SizingMethod = 'auto expand')"; * IE8 * / filter: progid:DXImageTransform.Microsoft.Matrix (M11 = 1.5, M12 = 0, M21 = 0, M22 = 1.5, SizingMethod = 'auto expand'); {/ * IE6 and 7 * /} .each-post a {color: #333;} 
 text-decoration: none; 
 display: block; 
 padding: 10px; 
 width: 100%;
 box-shadow: 0 1px 3px 0 rgba (0,0,0,.1);

} .each-post: hover {color: #ff942a;}
 * Firefox * /-moz-transition: all 0.3 s ease-in;
 * WebKit * /-webkit-transition: all 0.3 s ease-in;
 * Opera * /-o-transition: all 0.3 s ease-in;
 * Standard * / transition: all 0.3 s ease-in;
} @media only screen and (max-width: 580px) {/ * put your Responsive CSS here * /} 

here is the result:

3. View your “Cookie Consent” without plugin

since that the law on the protection of personal data requires web sites to inform visitors about the use of cookies, plugins for this purpose have never had so much wind in its sails! And yet it is so simple to add a small piece of code to its theme to install this notification bar, especially as there are very good tools to easily generate the code…

How do I? Here are the steps to follow:

  1. build code to add online: go to Skilltide.com or Cookie – Script.com follow the few steps, and then copy the code that will be provided.
  2. Duplicate the file header.php your parent
  3. theme

  4. using a text editor, open the file and add the resulting code (see also the present example below) just after the opening of the tag.
  5. Send the file header.php in your child theme via FTP (if the child theme is already present on your server).

See the code for the file header.php

     

here is the result:

Barre de cookies sans plugins

4. The function of “Duplicate Post” without plugin

native, WordPress allows you to create, edit or delete a post but unfortunately it does not duplicate an already existing post…

This feature would be very useful because it would allow you to win a considerable time depending on the use you made. There is a plugin that is very effective for this operation, it’s Duplicate Post , otherwise you can test the method without plugin which is just as effective for this:

  1. edit the file function.php to your child theme
  2. copy the code below and paste it into your file
  3. save and enjoy! As if by magic, the duplication option appeared on the side of your site admin. You will find it by hovering your cursor over an existing article.

See the code for the file functions.php

 / * Add the function to duplicate the posts without plugins * / function dupliquer_sans_plugin() {global $wpdb;
 If (!) (isset ($_GET ['post']): isset ($_POST ['post']) |) ((isset($_REQUEST['action']) & 'dupliquer_sans_plugin' == $_REQUEST ['action'])) ) {wp_die ("no post to duplicate was provided...");
 } / / GET the info A duplicate $post_id = (isset($_GET['post'])? absint ($_GET ['post']): absint ($_POST ['post']));
 $post = get_post ($post_id);
 $current_user = wp_get_current_user();
 $new_post_author = $current_user-> ID; or $new_post_author = $post-> post_author; to keep the author of origin if (isset ($post) & $post! = null) {/ / settings of the new draft $args = array ('comment_status'-online $post-> comment_status, 'ping_status'-online $post-> ping_status, 'post_author' => $new_post_author 'post_content'-online $post-> post_content, 'post_excerpt'-online $post-> post_excerpt, 'post_name'-online $post-> post_name, 'post_parent'-online $post-> post_parent, 'post_password'-online $post-> post_password, 'post_status'-online 'draft', 'post_title'-online $post-> post_title)} (, 'post_type'-online $post-> post_type, 'to_ping'-online $post-> to_ping, 'menu_order'-online $post-> menu_order);
 
 $new_post_id = wp_insert_post ($args);
 
 $taxonomies = get_object_taxonomies ($post-> post_type);
 foreach ($taxonomies as $taxonomy) {$post_terms = wp_get_object_terms ($post_id, $taxonomy, array ('fields'-online 'slugs'));}
 wp_set_object_terms($new_post_id, $post_terms, $taxonomy, false);
 } $post_meta_infos = $wpdb-> get_results("SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$post_id");
 If (count ($post_meta_infos)! = 0) {$sql_query = "INSERT INTO $wpdb-> postmeta (post_id, meta_key, meta_value)";
 foreach ($post_meta_infos as $meta_info) {$meta_key = $meta_info-> meta_key;
 $meta_value = addslashes ($meta_info-> meta_value);
 $sql_query_sel [] = "SELECT $new_post_id, ' $meta_key ', ' $meta_value '";
 } $sql_query. = implode("UNION ALL", $sql_query_sel);
 $wpdb-> query ($sql_query);
 } wp_redirect (admin_url (' post.php? action = edit & post ='. $new_post_id));
 exit;
 } else {wp_die("Une erreur s'est produite, impossible de trouver le post original:".) $post_id);
 }} add_action ('admin_action_dupliquer_sans_plugin', 'dupliquer_sans_plugin');
 
function dupliquer_le_post ($actions, $post) {if (current_user_can ('edit_posts')) {$actions ['duplicate'] = ' ';
 } return $actions;
} add_filter ('post_row_actions', 'dupliquer_le_post', 10, 2); 

See the result:

Dulicate post sans plugins

5. Put its maintenance without plugin WordPress

this is a fine example of feature that could easily happen a plugin! To do this, simply add just a few lines of code in the file functions.php to your child theme. With this function, you will continue to access your administration continue to work quietly on your site as proposed by maintenance plugins. All visitors who will not be identified as administrators, they will see a “site under maintenance” page.

From the code available below, you can very well imagine to add a section of links to your social networks, an insert of inscription to the newsletter, a background image etc… And that is, a less plugin!

NB: the advantage with this piece of code is that once you have completed your changes, simply put the code “Paused” until the next works with a double slash (/ /) inserted before each line. You can easily do so since your administration tab appearance > editor > functions.php

see the code for the file functions.php

 / * maintenance page side visitor - without plugins * / function mode_maintenance() {if (! current_user_can ('edit_themes') |! is_user_logged_in()) {wp_die('

Site en Maintenance

Nous effectuons quelques travaux de maintenance afin de vous fournir un site toujours plus efficace...)} Come back soon!

(
'); }} add_action ('get_header', 'mode_maintenance');

Put mode maintenance paused

 //function mode_maintenance() {/ / if (! current_user_can ('edit_themes') |! is_user_logged_in()) {/ / wp_die('

Site en Maintenance

Nous effectuons quelques travaux de maintenance afin de vous fournir un site toujours plus efficace...)}} Come back soon!

(
'); {} / /} //add_action ('get_header', 'mode_maintenance');

See the result:

Mode maintenance sans plugins

in conclusion

you’ll understand that the plugins are bits of code that add functionality to a WordPress site. If you were a developer, you would certainly not need them (or very little), certainly, but nothing prevents you from finding the right balance…

Then, at work?