View customizer.php
<?php | |
// In folderul themes creati un folder inc daca nu-l aveti deja. | |
// In acest folder creati un fisier customizer.php | |
// ( el poate sa fie salvat si sub alt nume, eu doar am pus acest nume pentru ca e sugestiv). | |
// In interiorul acestui fisier (customizer.php) copy paste la functia prefix_customizer_register. | |
// prefix_ ar trebui inlocuit cu numele theme-ului vostru. Ex: bogdan_customizer_register | |
// La fel si textdomain-ul. | |
function prefix_customizer_register( $wp_customize ) { |
View query-by-cat.php
<?php | |
// Query arguments : https://codex.wordpress.org/Class_Reference/WP_Query | |
$args = array( | |
'posts_per_page'=> 5, | |
'orderby' => 'date', | |
'order' => 'DESC', | |
'category' => 'slider' | |
); | |
// create the query |
View gist:7d06a4b0f8deb5c94b7c04a11d715ed3
function rbpixel_customize_wc_errors( $error ) { | |
if ( strpos( $error, 'Billing ' ) !== false ) { | |
$error = str_replace("Billing ", "", $error); | |
} | |
return $error; | |
} | |
add_filter( 'woocommerce_add_error', 'rbpixel_customize_wc_errors' ); |
View .htaccess
# BEGIN WordPress | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteBase / | |
RewriteRule ^index\.php$ - [L] | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule . /index.php [L] | |
</IfModule> |
View add_image_to_rss_wp
// Add the image node to RSS feed | |
add_action('rss2_item', 'add_featured_image_as_rss_node'); | |
function add_featured_image_as_rss_node() { | |
global $post; | |
if(has_post_thumbnail($post->ID)): | |
$thumbnail = wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) ); | |
echo("<image>{$thumbnail}</image>"); | |
endif; | |
} |
View array-insert-after.php
<?php | |
/** | |
* Insert a value or key/value pair after a specific key in an array. If key doesn't exist, value is appended | |
* to the end of the array. | |
* | |
* @param array $array | |
* @param string $key | |
* @param array $new | |
* |
View .htaccess
# BLOCK PROXY VISITS | |
# PerishablePress.com: http://bit.ly/12k6Uo | |
<ifModule mod_rewrite.c> | |
RewriteEngine on | |
RewriteCond %{HTTP:VIA} !^$ [OR] | |
RewriteCond %{HTTP:FORWARDED} !^$ [OR] | |
RewriteCond %{HTTP:USERAGENT_VIA} !^$ [OR] | |
RewriteCond %{HTTP:X_FORWARDED_FOR} !^$ [OR] | |
RewriteCond %{HTTP:PROXY_CONNECTION} !^$ [OR] | |
RewriteCond %{HTTP:XPROXY_CONNECTION} !^$ [OR] |
View new-rewrite.php
/** | |
* Add new rewrite rule | |
*/ | |
function create_new_url_querystring() { | |
add_rewrite_rule( | |
'blog/([^/]*)$', | |
'index.php?name=$matches[1]', | |
'top' | |
); | |
add_rewrite_tag('%blog%','([^/]*)'); |
View gist:d6a709116ae90ad8beda81b60ed9fb27
$user_name = 'username'; | |
$user_email = 'email'; | |
$random_password = wp_generate_password( $length=12, $include_standard_special_chars=false ); | |
$user_id = username_exists( $user_name ); | |
if ( !$user_id and email_exists($user_email) == false ) { | |
$user_id = wp_create_user( $user_name, $random_password, $user_email ); | |
$user = get_user_by( 'id', $user_id ); | |
// Remove role | |
$user->remove_role( 'subscriber' ); |
View security-tips.php
/* | |
* this code goes in your theme`s functions.php file | |
*/ | |
add_filter('login_errors',create_function('$a', "return null;")); | |
define( 'DISALLOW_FILE_EDIT', true ); | |
function no_wordpress_errors(){ | |
return 'Nothing to see here, move along!'; | |
} |
NewerOlder