This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//add discreet text widget | |
add_action('widgets_init', 'custom_discreet_text_widget'); | |
function custom_discreet_text_widget() { | |
class DiscreetTextWidget extends WP_Widget_Text { | |
function DiscreetTextWidget() { | |
$widget_ops = array('classname' => 'discreet_text_widget', 'description' => __('Arbitrary text or HTML, only shown if not empty')); | |
$control_ops = array('width' => 400, 'height' => 350); | |
$this->WP_Widget('discrete_text', __('Discreet Text'), $widget_ops, $control_ops); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function wpr_snap($atts, $content = null) { | |
extract(shortcode_atts(array( | |
"snap" => 'http://s.wordpress.com/mshots/v1/', | |
"url" => 'http://www.sagive.co.il', | |
"alt" => 'My image', | |
"w" => '400', // width | |
"h" => '300' // height | |
), $atts)); | |
$img = '<img src="' . $snap . '' . urlencode($url) . '?w=' . $w . '&h=' . $h . '" alt="' . $alt . '"/>'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_shortcode('field', 'shortcode_field'); | |
function shortcode_field($atts){ | |
extract(shortcode_atts(array( | |
'post_id' => NULL, | |
), $atts)); | |
if(!isset($atts[0])) return; | |
$field = esc_attr($atts[0]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//removing and improving the excerpt | |
remove_filter('get_the_excerpt', 'wp_trim_excerpt'); | |
add_filter('get_the_excerpt', 'improved_trim_excerpt'); | |
/*improve the excerpt, keep HTML in there*/ | |
function improved_trim_excerpt($text) { | |
global $post; | |
if ( '' == $text ) { | |
$text = get_the_content(''); | |
$text = apply_filters('the_content', $text); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function my_home_category( $query ) { | |
if ( $query->is_home() && $query->is_main_query() ) { | |
$query->set( 'cat', '11'); | |
} | |
} | |
add_action( 'pre_get_posts', 'my_home_category' ); | |
//If you would like to include more than one category, then just add another ID by inserting a comma and the ID number. For example, this is will display category 11 and category 14. | |
//$query->set( 'cat', ’11, 14’ ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Paste this code into a text widget to put a qr code on each page. | |
<script type="text/javascript"> | |
var url=encodeURIComponent(window.location); | |
var qr="<img style=\"maxwidth:100%\" src=\"https://chart.googleapis.com/chart?chs=240x240&cht=qr&chl="+url+"&choe=UTF-8\"/>"; | |
document.open(); | |
document.write(qr); | |
document.close(); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'wp_mail_from', 'my_mail_from' ); | |
function my_mail_from( $email ) | |
{ | |
return "change-this-to-your-email-address"; | |
} | |
add_filter( 'wp_mail_from_name', 'my_mail_from_name' ); | |
function my_mail_from_name( $name ) | |
{ | |
return "My Name"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('phpmailer_init','send_smtp_email'); | |
function send_smtp_email( $phpmailer ) | |
{ | |
// Define that we are sending with SMTP | |
$phpmailer->isSMTP(); | |
// The hostname of the mail server | |
$phpmailer->Host = "smtp.example.com"; | |
// Use SMTP authentication (true|false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function clear_br($content){ | |
return str_replace("<br />","<br clear='none'/>", $content); | |
} | |
add_filter('the_content', 'clear_br'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* letter counter */ | |
add_action( 'admin_head-post.php', 'letter_count_js')); | |
add_action( 'admin_head-post-new.php', 'letter_count_js' )); | |
public function letter_count_js(){ echo '<script>jQuery(document).ready(function(){ jQuery("#postexcerpt .handlediv").after("<input type=\'text\' value=\'0\' maxlength=\'3\' size=\'3\' id=\'excerpt_counter\' readonly=\'\' style=\'background:#fff; position:absolute;top:0.2em;right:2em; color:#666;\'>"); jQuery("#excerpt_counter").val(jQuery("#excerpt").val().length); jQuery("#excerpt").keyup( function() {jQuery("#excerpt_counter").val(jQuery("#excerpt").val().length); }); jQuery("#wp-word-count").after("<td id=\'wp-character-count\'>Character count: <span class=\'character-count\'>0</span></td>"); jQuery("#wp-character-count .character-count").html(jQuery("#wp-content-wrap .wp-editor-area").val().length); jQuery("#wp-content-wrap .wp-editor-area").keyup( function() {jQuery("#wp-character-count .character-count").html(jQuery("#wp-content-wrap .wp-editor-area").val().length |
NewerOlder