Skip to content

Instantly share code, notes, and snippets.

@karrikas
karrikas / robots.txt
Last active April 15, 2016 12:40
robots.txt file for wordpress
# http://jvalenzuela.es/robots-txt-para-wordpress/
User-agent: *
Disallow: /wp-login
Disallow: /wp-admin
Disallow: //wp-includes/
Disallow: /*/feed/
Disallow: /*/trackback/
Disallow: /*/attachment/
Disallow: /author/
Disallow: /*/page/
@karrikas
karrikas / functions.php
Created May 4, 2016 11:07
Bootstrap pagination for Wordpress
function wp_bootstrap_pagination()
{
if( is_singular() ) {
return;
}
global $wp_query;
if( $wp_query->max_num_pages <= 1 ) {
@karrikas
karrikas / functions.php
Last active June 15, 2016 13:26
WPML Custom language menu
<?php
function wpml_languages_list() {
$languages = icl_get_languages('skip_missing=0');
if(!empty($languages)){
echo '<div id="icl_lagunage_menu"><ul>';
foreach($languages as $l){
echo '<li>';
if($l['active']) {
$class = ' class="active"';
}
@karrikas
karrikas / funtions.cfc
Created October 4, 2016 08:26
Know Ascii code of each character over a string in coldfusion
<cfargument name="testua" default="0">
<cfloop index="intChar" from="1" to="#Len( testua )#" step="1">
<cfset strChar = Mid( testua, intChar, 1 ) />
<cfdump var="[#intChar#:#asc(strChar)#:#strChar#]">
</cfloop>
<cfabort>
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
@karrikas
karrikas / functions.php
Created January 11, 2017 14:37
Phpmailer wordpress, disable SSL certificate check [allow_self_signed]
<?php
add_action( 'phpmailer_init', 'phpmailer_disable_self_signed' );
function phpmailer_disable_self_signed( PHPMailer $phpmailer ) {
$phpmailer->SMTPOptions = ['ssl'=> ['allow_self_signed' => true]];
}
@karrikas
karrikas / *.sublime-project
Created January 12, 2017 09:58
Sublime text disable phpcs in a project
{
"folders":
[
{
"path": "project/path/here"
}
],
"settings": {
"phpcs": {
"phpcs_execute_on_save": false,
@karrikas
karrikas / functions.php
Created February 24, 2017 09:41
Add bootstrap responsive embed to wordpress automatic media embed and iframes
<?php
// your custom code...
add_filter('embed_oembed_html', 'my_embed_oembed_html', 10, 4);
function my_embed_oembed_html($html, $url, $attr, $post_ID) {
$iframe = str_replace('<iframe', '<iframe class="embed-responsive-item"', $html);
$newHtml = '<div class="embed-responsive embed-responsive-16by9">%s</iframe></div>';
$html = sprintf($newHtml, $iframe);
return $html;
@karrikas
karrikas / send-push.php
Last active July 2, 2018 10:57
Firebase push notification by PHP example, cordova FCM_PLUGIN
<?php
// API access key from Google API's Console
define('API_ACCESS_KEY', 'your-key');
function pushMessage($title, $body, $sound = true)
{
$msg = array (
'body' => substr($body,0,40), // limit body
'title' => $title,
'click_action' => 'FCM_PLUGIN_ACTIVITY',
@karrikas
karrikas / gulpfile.js
Last active August 29, 2017 11:27
Gulp deploy web by rsync
var gulp = require('gulp');
var shell = require('gulp-shell');
var prompt = require('gulp-prompt');
var init = {
ssh: {
user: "",
host: "",
port: "22",
path: ""