The post JavaScript & jQuery: kaskadowe łączenie wywołań (ang. method chaining) appeared first on JavaScript, NodeJS, AngularJS & WordPress.
]]>Dla przykładu w vanilla JavaScript może to wyglądać następująco:
var value = 0;
var obj = {
increase: function(val) {
value = value + val;
return obj;
},
decrease: function(val) {
value = value - val;
return obj;
}
}
obj.increase(5).increase(2).decrease(1);
console.log(value); // 6
W jQuery chcemy zwrócić "this" - jsFiddle demo:
$.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");
};
$.fn.innTxt = function (txt) {
return $(this).html(txt);
};
$('#main').redBorder().greyBackground().innTxt("testing chaining");
The post JavaScript & jQuery: kaskadowe łączenie wywołań (ang. method chaining) appeared first on JavaScript, NodeJS, AngularJS & WordPress.
]]>The post Git na Windows: jak zapisac hasło https appeared first on JavaScript, NodeJS, AngularJS & WordPress.
]]>Jest narzędzie, które będzie w stanie zapisać dla Ciebie hasła oraz nazwy użytkowników przy połączeniach GIT przez HTTPS – git-credential-winstore.
Pobrać można tutaj: http://gitcredentialstore.codeplex.com/
The post Git na Windows: jak zapisac hasło https appeared first on JavaScript, NodeJS, AngularJS & WordPress.
]]>The post JavaScript: jak znaleźć liczby pierwsze (prime numbers) appeared first on JavaScript, NodeJS, AngularJS & WordPress.
]]>W naszym przykładzie wykorzystamy dwie funkcje:
Funkcja, która pozwoli sprawdzić czy liczba jest liczbą pierwszą może wyglądać następująco:
function isPrime(num) {
if(num < 2) return false;
for (var i = 2; i < num; i++) {
if(num % i == 0)
return false;
}
return true;
}Kilka ważnych uwag:
Teraz dla przykładu chcemy uzyskać wszystkie liczby pierwsza mniejsze niż 100:
var arr = [];
for(var i = 0; i < 100; i++){
if(isPrime(i)) { arr.push(i); }
}
console.log(arr);
console.log(arr.length);Oraz kolejny przykład jak znaleźć 100 pierwszych liczb pierwszych:
var arr = [];
var x = 0;
while(arr.length < 100){
if(isPrime(x)) { arr.push(x); }
x++;
}
console.log(arr);
console.log(arr.length)
The post JavaScript: jak znaleźć liczby pierwsze (prime numbers) appeared first on JavaScript, NodeJS, AngularJS & WordPress.
]]>The post WordPress: jak wyłączyć przypomnienia o updatach appeared first on JavaScript, NodeJS, AngularJS & WordPress.
]]>
Użyj kodu poniżej, aby wyłączyć updaty dla pluginow, wordpress core or themes:
// 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' );
// Diasable Core Updates # 3.0+
add_filter( 'pre_site_transient_update_core', create_function( '$a', "return null;" ) );
wp_clear_scheduled_hook( 'wp_version_check' );The post WordPress: jak wyłączyć przypomnienia o updatach appeared first on JavaScript, NodeJS, AngularJS & WordPress.
]]>The post WordPress 3.8 – opcja ilości kolumn w dashboardzie appeared first on JavaScript, NodeJS, AngularJS & WordPress.
]]>function dashboard_columns() {
add_screen_option(
'layout_columns',
array(
'max' => 4,
'default' => 1
)
);
}
add_action( 'admin_head-index.php', 'dashboard_columns' );
The post WordPress 3.8 – opcja ilości kolumn w dashboardzie appeared first on JavaScript, NodeJS, AngularJS & WordPress.
]]>The post WordPress: jak usunąć logo WordPress z ekranu logowania appeared first on JavaScript, NodeJS, AngularJS & WordPress.
]]>// 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');The post WordPress: jak usunąć logo WordPress z ekranu logowania appeared first on JavaScript, NodeJS, AngularJS & WordPress.
]]>The post WordPress: wlasny breadcrumb bez pluginu appeared first on JavaScript, NodeJS, AngularJS & WordPress.
]]>function the_breadcrumbs() {
global $post;
global $wp_query;
if ( ! is_home() ) {
echo "<li><a href='http://website.com/'>WebSite</a></li>";
echo "<li><a href='";
echo get_option('home');
echo "'>";
echo bloginfo('name');
echo "</a></li>";
if (is_category() || is_single()) {
//echo "<li>";
$cats = get_the_category( $post->ID );
//echo "</li>";
foreach ( $cats as $cat ){
//var_dump($cat);
echo "<li>";
echo "<a href='".get_category_link($cat->term_id)."'>".$cat->cat_name."</a>";
echo "</li>";
}
if ( is_single()) {
echo "<li>";
the_title();
echo "</li>";
}
} elseif (is_page()) {
$post = $wp_query->get_queried_object();
if ( $post->post_parent == 0 ){
echo "<li> ".the_title('','', FALSE)."</li>";
} else {
$title = the_title('','', FALSE);
$ancestors = array_reverse( get_post_ancestors( $post->ID ) );
array_push($ancestors, $post->ID);
foreach ( $ancestors as $ancestor ){
if( $ancestor != end($ancestors) ){
echo '<li><a href="'. get_permalink($ancestor) .'">'. strip_tags( apply_filters( 'single_post_title', get_the_title( $ancestor ) ) ) .'</a></li>';
} else {
echo '<li>'. strip_tags( apply_filters( 'single_post_title', get_the_title( $ancestor ) ) ) .'</li>';
}
}
}
}
}
elseif (is_tag()) { single_tag_title(); }
elseif (is_day()) { echo"Archive: "; the_time('F jS, Y'); echo'</li>';}
elseif (is_month()) { echo"Archive: "; the_time('F, Y'); echo'</li>';}
elseif (is_year()) { echo"Archive: "; the_time('Y'); echo'</li>';}
elseif (is_author()) { echo"Author's archive: "; echo'</li>';}
elseif (isset($_GET['paged']) && !empty($_GET['paged'])) {echo "Blogarchive: "; echo'';}
elseif (is_search()) { echo"Search results: "; }
}Później używamy jak poniżej:
<!-- BREADCRUMB -->
<?php if( function_exists('the_breadcrumbs') ) { ?>
<ol class='breadcrumb '>
<?php the_breadcrumbs(); ?>
</ol>
<?php } ?>
<!-- // BREADCRUMB -->
The post WordPress: wlasny breadcrumb bez pluginu appeared first on JavaScript, NodeJS, AngularJS & WordPress.
]]>The post WordPress: jak zaladowac domysle style dla wordpress theme – plik style.css appeared first on JavaScript, NodeJS, AngularJS & WordPress.
]]><link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" />
W ramach przypomnienia plik style.css moglby wygladac tak:
/*
Theme Name: ThemeName
Author: John Doe @ CompanyCo LTD
Author E-mail: [email protected]
Author URI: http://john.company.com
Version: 1.0
Last Update: 12/12/2012
*/The post WordPress: jak zaladowac domysle style dla wordpress theme – plik style.css appeared first on JavaScript, NodeJS, AngularJS & WordPress.
]]>The post WordPress: lista adresów e-mail dla danej roli appeared first on JavaScript, NodeJS, AngularJS & WordPress.
]]>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;
}
return $arr;
}The post WordPress: lista adresów e-mail dla danej roli appeared first on JavaScript, NodeJS, AngularJS & WordPress.
]]>