diff -r 0d9a58d2c515 -r 0d28b7c10758 web/wp-content/themes/newsworthy/functions.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/wp-content/themes/newsworthy/functions.php Fri Mar 12 13:29:04 2010 +0000 @@ -0,0 +1,244 @@ + array( +"name" => "newsworthy_image", +"std" => "", +"title" => "Featured Image", +"description" => "Using the \"Add an Image\" button, upload a 610x281 image and paste the URL here. Displayed in full size for the featured post, resized versions for single posts and substories on index pages are handled automatically.") +); +function new_meta_boxes() { +global $post, $new_meta_boxes; + +foreach($new_meta_boxes as $meta_box) { +$meta_box_value = get_post_meta($post->ID, $meta_box['name'].'_value', true); + +if($meta_box_value == "") +$meta_box_value = $meta_box['std']; + +echo''; + +echo'

'.$meta_box['title'].'

'; + +echo'
'; + +echo'

'; +} +} +function create_meta_box() { +global $theme_name; +if ( function_exists('add_meta_box') ) { +add_meta_box( 'new-meta-boxes', 'Newsworthy Post Settings', 'new_meta_boxes', 'post', 'normal', 'high' ); +} +} +function save_postdata( $post_id ) { +global $post, $new_meta_boxes; + +foreach($new_meta_boxes as $meta_box) { +// Verify +if ( !wp_verify_nonce( $_POST[$meta_box['name'].'_noncename'], plugin_basename(__FILE__) )) { +return $post_id; +} + +if ( 'page' == $_POST['post_type'] ) { +if ( !current_user_can( 'edit_page', $post_id )) +return $post_id; +} else { +if ( !current_user_can( 'edit_post', $post_id )) +return $post_id; +} + +$data = $_POST[$meta_box['name'].'_value']; + +if(get_post_meta($post_id, $meta_box['name'].'_value') == "") +add_post_meta($post_id, $meta_box['name'].'_value', $data, true); +elseif($data != get_post_meta($post_id, $meta_box['name'].'_value', true)) +update_post_meta($post_id, $meta_box['name'].'_value', $data); +elseif($data == "") +delete_post_meta($post_id, $meta_box['name'].'_value', get_post_meta($post_id, $meta_box['name'].'_value', true)); +} +} +add_action('admin_menu', 'create_meta_box'); +add_action('save_post', 'save_postdata'); +function the_content_limit($max_char, $more_link_text = '(more...)', $stripteaser = 0, $more_file = '') { + $content = get_the_content($more_link_text, $stripteaser, $more_file); + $content = apply_filters('the_content', $content); + $content = str_replace(']]>', ']]>', $content); + + if (strlen($_GET['p']) > 0) { + echo $content; + } + else if ((strlen($content)>$max_char) && ($espacio = strpos($content, " ", $max_char ))) { + $content = substr($content, 0, $espacio); + $content = $content; + echo $content; + echo "

"; + } + else { + echo $content; + } +} +class My_125_Widget extends WP_Widget { + function My_125_Widget() { + $widget_ops = array('classname' => 'widget_125_ad', 'description' => 'A single 125x125 ad banner' ); + $this->WP_Widget('125_ad', '125x125 Ad', $widget_ops); + } + + function widget($args, $instance) { + extract($args, EXTR_SKIP); + + echo $before_widget; + $image_url = empty($instance['image_url']) ? '' : apply_filters('widget_image_url', $instance['image_url']); + $image_alt = empty($instance['image_alt']) ? '' : apply_filters('widget_image_alt', $instance['image_alt']); + $image_link = empty($instance['image_link']) ? '' : apply_filters('widget_image_link', $instance['image_link']); + + if ( !empty( $title ) ) { echo $before_title . $title . $after_title; }; + echo ''; + echo ''; + echo ''; + echo $after_widget; + } + + function update($new_instance, $old_instance) { + $instance = $old_instance; + $instance['image_url'] = strip_tags($new_instance['image_url']); + $instance['image_alt'] = strip_tags($new_instance['image_alt']); + $instance['image_link'] = strip_tags($new_instance['image_link']); + + return $instance; + } + + function form($instance) { + $instance = wp_parse_args( (array) $instance, array( 'image_url' => '', 'image_alt' => '', 'image_link' => '' ) ); + $image_url = strip_tags($instance['image_url']); + $image_alt = strip_tags($instance['image_alt']); + $image_link = strip_tags($instance['image_link']); +?> +

+

+

+ 'Tabber', + 'before_widget' => '
', + 'after_widget' => '
 
', + 'before_title' => '

', + 'after_title' => '

', + )); +if ( function_exists('register_sidebar') ) + register_sidebar(array( + 'name' => 'Sidebar Ads', + 'before_widget' => '', + 'after_widget' => '', + 'before_title' => '', + 'after_title' => '', + )); +if ( function_exists('register_sidebar') ) + register_sidebar(array( + 'name' => 'Sidebar Left', + 'before_widget' => '', + 'after_widget' => '', + 'before_title' => '

', + 'after_title' => '

', + )); +if ( function_exists('register_sidebar') ) + register_sidebar(array( + 'name' => 'Sidebar Right', + 'before_widget' => '', + 'after_widget' => '', + 'before_title' => '

', + 'after_title' => '

', + )); +if ( function_exists('register_sidebar') ) + register_sidebar(array( + 'name' => 'Sidebar Bottom', + 'before_widget' => '', + 'after_widget' => '', + 'before_title' => '

', + 'after_title' => '

', + )); +if ( function_exists('register_sidebar') ) + register_sidebar(array( + 'name' => 'Footer One', + 'before_widget' => '', + 'after_widget' => '', + 'before_title' => '

', + 'after_title' => '

', + )); +if ( function_exists('register_sidebar') ) + register_sidebar(array( + 'name' => 'Footer Two', + 'before_widget' => '', + 'after_widget' => '', + 'before_title' => '

', + 'after_title' => '

', + )); +if ( function_exists('register_sidebar') ) + register_sidebar(array( + 'name' => 'Footer Three', + 'before_widget' => '', + 'after_widget' => '', + 'before_title' => '

', + 'after_title' => '

', + )); +if ( function_exists('register_sidebar') ) + register_sidebar(array( + 'name' => 'Footer Four', + 'before_widget' => '', + 'after_widget' => '', + 'before_title' => '

', + 'after_title' => '

', + )); +if ( function_exists('register_sidebar') ) + register_sidebar(array( + 'name' => 'Footer Five', + 'before_widget' => '', + 'after_widget' => '', + 'before_title' => '

', + 'after_title' => '

', + )); +if ( function_exists('register_sidebar') ) + register_sidebar(array( + 'name' => 'Single Middle', + 'before_widget' => '', + 'after_widget' => '', + 'before_title' => '

', + 'after_title' => '

', + )); +if ( function_exists('register_sidebar') ) + register_sidebar(array( + 'name' => 'Home Middle', + 'before_widget' => '', + 'after_widget' => '', + 'before_title' => '

', + 'after_title' => '

', + )); +if ( function_exists('register_sidebar') ) + register_sidebar(array( + 'name' => 'Home Left', + 'before_widget' => '', + 'after_widget' => '', + 'before_title' => '

', + 'after_title' => '

', + )); +if ( function_exists('register_sidebar') ) + register_sidebar(array( + 'name' => 'Home Right', + 'before_widget' => '', + 'after_widget' => '', + 'before_title' => '

', + 'after_title' => '

', + )); +if ( function_exists('register_sidebar') ) + register_sidebar(array( + 'name' => '404', + 'before_widget' => '', + 'after_widget' => '', + 'before_title' => '

', + 'after_title' => '

', + )); +?> \ No newline at end of file