Skip to content

Instantly share code, notes, and snippets.

<?php /* Template Name: Custom Template */ ?>
<?php get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
// Start the loop.
while ( have_posts() ) : the_post();
@ai2ik
ai2ik / Delete old wp posts
Last active August 1, 2018 19:45
Delete old wp posts by date
function get_delete_old_post()
{
// WP_Query arguments
$args = array(
'fields' => 'ids', // Only get post ID's to improve performance
'post_type' => array(
'post'
) , //post type if you are using default than it will be post
# Click RAW button above, select all and copy (Ctrl-C) then paste (Ctrl-V) before all other rules in .htaccess file
# Wish to "deny" countries from accessing your site, see IP2Location: http://www.ip2location.com/blockvisitorsbycountry.aspx
RewriteEngine on
# Security related. Block browser access to log files
<Files ~ "\.log$">
Order allow,deny
</Files>
@ai2ik
ai2ik / style.css
Last active October 1, 2018 18:30
WP Child theme CSS
/*
Theme Name: Child Theme
Template: wp-bootstrap-starter
*/
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
remove_action('wp_head', 'rsd_link'); //removes EditURI/RSD (Really Simple Discovery) link.
remove_action('wp_head', 'wlwmanifest_link'); //removes wlwmanifest (Windows Live Writer) link.
remove_action('wp_head', 'wp_generator'); //removes meta name generator.
remove_action('wp_head', 'wp_shortlink_wp_head'); //removes shortlink.
remove_action('wp_head', 'feed_links', 2 ); //removes feed links.
remove_action('wp_head', 'feed_links_extra', 3 ); //removes comments feed.
remove_action('wp_head', 'wp_resource_hints', 2 ); // remove WP 4.9+ dns-prefetch
remove_action('wp_head', 'print_emoji_detection_script', 7 ); // remove WP 4.2+ emoji
remove_action('admin_print_scripts', 'print_emoji_detection_script' ); // remove WP 4.2+ emoji
remove_action('wp_print_styles', 'print_emoji_styles' ); // remove WP 4.2+ emoji
// wp_html_compression
class WP_HTML_Compression
{
// Settings
protected $compress_css = true;
protected $compress_js = true;
protected $info_comment = true;
protected $remove_comments = true;
// Variables
@ai2ik
ai2ik / Adding script to the head with wp_head
Created December 28, 2018 18:16
To manually add script to the head of a WordPress site you can use the wp_head action by using one of the the following function examples in function.php If using the echo function you will need to use double quotes around scripts single quotes to keep from breaking the function.
<?php
/**
* add script to head with wrapping php
*/
function addtohead_cf() {
?>
<script></script>
<?php
}
add_action('wp_head', 'addtohead_cf');
@ai2ik
ai2ik / Track In-Page Events
Created December 28, 2018 18:23
After you install the pixel track in-page actions, such as product purchases, by tying events to HTML elements such as buttons. For example:
<button onClick="fbq('track', 'Purchase');">Button Text</button>
Or you could create a function that pushes the event. The advantage is if you have multiple HTML elements, you can call a single function when someone clicks any of them; you don't have to define individual onClick element.
For example, to push the event:
<script>
function onClick() {
fbq('track', 'Purchase');
};
</script>
apt install roundcube-core roundcube-mysql roundcube-plugins
wget http://c.vestacp.com/0.9.8/debian/apache2-webmail.conf -O /etc/roundcube/apache.conf
nano /etc/roundcube/debian-db.php (enter password)
cd /usr/share
mv roundcube roundcube-bk
rm -r roundcube
wget https://github.com/roundcube/roundcubemail/releases/download/1.3.7/roundcubemail-1.3.7-complete.tar.gz
tar -xvf roundcubemail-1.3.7-complete.tar.gz
mv roundcubemail-1.3.7-complete roundcube
rm -r /usr/share/roundcube/installer