Skip to content

Instantly share code, notes, and snippets.

@iladarsda
iladarsda / get_emails_by_role.php
Last active August 29, 2015 13:56
WordPress code snippets
function get_emails_by_role($role) {
$arr = array();
$args = array("role" => $role);
$users = get_users($args );
foreach ($users as $key => $value) {
$arr[] = $value->data->user_email;
}
@iladarsda
iladarsda / style.css
Created February 7, 2014 10:15
WordPress: example style.css file
/*
Theme Name: ThemeName
Author: John Doe @ CompanyCo LTD
Author E-mail: john.doe@company.com
Author URI: http://john.company.com
Version: 1.0
Last Update: 12/12/2012
*/
@iladarsda
iladarsda / breadcrumbs.php
Created February 7, 2014 10:19
WordPress: good breadcrumb example
<!-- BREADCRUMB -->
<?php if( function_exists('the_breadcrumbs') ) { ?>
<ol class='breadcrumb '>
<?php the_breadcrumbs(); ?>
</ol>
<?php } ?>
<!-- // BREADCRUMB -->
@iladarsda
iladarsda / wordpress_no_logo.php
Created February 7, 2014 10:27
WordPress login page, disable wordpress logo
// Login Page - No logo
function new_custom_login_logo() {
echo "<style type='text/css'>h1 { display: none !important; } </style>";
}
add_action('login_head', 'new_custom_login_logo');
@iladarsda
iladarsda / dash.php
Created February 7, 2014 10:32
Wordpress 3.8 - enable number of dashboard column in dashboard
function dashboard_columns() {
add_screen_option(
'layout_columns',
array(
'max' => 4,
'default' => 1
)
);
}
add_action( 'admin_head-index.php', 'dashboard_columns' );
@iladarsda
iladarsda / disable_updates.php
Created February 7, 2014 10:46
WordPress: disable updates
// Disable Theme Updates # 3.0+
remove_action( 'load-update-core.php', 'wp_update_themes' );
add_filter( 'pre_site_transient_update_themes', create_function( '$a', "return null;" ) );
wp_clear_scheduled_hook( 'wp_update_themes' );
// Disable Plugin Updates #3.0+
remove_action( 'load-update-core.php', 'wp_update_plugins' );
add_filter( 'pre_site_transient_update_plugins', create_function( '$a', "return null;" ) );
wp_clear_scheduled_hook( 'wp_update_plugins' );
@iladarsda
iladarsda / first100primeNumbers.js
Last active August 29, 2015 13:56
JavaScript: find prime numbers
var arr = [];
var x = 0;
while(arr.length < 100){
if(isPrime(x)) { arr.push(x); }
x++;
}
console.log(arr);
console.log(arr.length)
@iladarsda
iladarsda / pattern.js
Created February 21, 2014 14:11
jQuery promise pattern
function doStuff(flag) {
var deferred = $.Deferred();
var err = null,
data = null;
if (flag) {
setTimeout(function() {
data = ["2", "2"];
deferred.resolve(err, data);
}, 5 * 1000)
} else {
@iladarsda
iladarsda / jquery.js
Created March 13, 2014 12:51
JavaScript - method chaining
$.fn.redBorder = function () {
$(this).css("border", "1px solid red");
return this;
// or shorter "return $(this).css("border", "1px solid red");"
};
$.fn.greyBackground = function () {
return $(this).css("background-color", "grey");
@iladarsda
iladarsda / javascript.js
Created May 10, 2014 19:13
jQuery/javascript running functions synchronously
function fun1() {
setTimeout(function() {
console.log("fun1 after 5 s..");
}, 5 * 1000);
return this;
};
function fun2() {
setTimeout(function() {
console.log("fun2 after another 15 s..");