Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2012
436
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 31.66 KB | None | 0 0
  1. <?php
  2. $themename = "uTeli";
  3. $shortname = "qf";
  4.  
  5. // Create theme options
  6.  
  7. $options = array (
  8.                
  9.                 array(  "desc" => __('<h2 style="margin-top:20px;">Modificar Logo</h2>'),
  10.                         "type" => "nothing"),
  11.                
  12.                 array(  "name" => __('Logo'),
  13.                         "desc" => __('Resoluci&oacute;n 240x53'),
  14.                         "id" => $shortname."_logo",
  15.                         "std" => "",
  16.                         "type" => "upload"),
  17.                
  18.                 array(  "desc" => __('<h2 style="margin-top:30px;">Modificar Favicon</h2>'),
  19.                         "type" => "nothing"),
  20.                
  21.                 array(  "name" => __('Favicon'),
  22.                         "desc" => __('Resoluci&oacute;n 16x16'),
  23.                         "id" => $shortname."_favicon",
  24.                         "std" => "",
  25.                         "type" => "upload"),
  26.  
  27.                 array(  "desc" => __('<h2>Header<i> <span style="font-size:12px; font-weight:500;">(Meta tags, Analytics, etc)</span></i></h2>'),
  28.                         "type" => "nothing"),
  29.                
  30.                 array(  "name" => __('Head'),
  31.                         "desc" => __('Codigos que van antes de cerrar &lt;/head&gt;'),
  32.                         "id" => $shortname."_head",
  33.                         "std" => __(""),
  34.                         "type" => "textarea",
  35.                         "options" => array( "rows" => "5",
  36.                                             "cols" => "100") ),
  37.                 array(  "desc" => __('<h2>Body<i> <span style="font-size:12px; font-weight:500;">(Infolink, Whos amung, etc)</span></i></h2>'),
  38.                         "type" => "nothing"),
  39.                
  40.                 array(  "name" => __('Body'),
  41.                         "desc" => __('Codigos que van antes de cerrar &lt;/body&gt;'),
  42.                         "id" => $shortname."_body",
  43.                         "std" => __(""),
  44.                         "type" => "textarea",
  45.                         "options" => array( "rows" => "5",
  46.                                             "cols" => "100") ),
  47.                 array(  "desc" => __('<h2>Footer<i> <span style="font-size:12px; font-weight:500;">(Texto del Footer)</span></i></h2>'),
  48.                         "type" => "nothing"),
  49.                
  50.                 array(  "name" => __('Texto Footer'),
  51.                         "desc" => __('Texto de Pie de Pagina'),
  52.                         "id" => $shortname."_tfooter",
  53.                         "std" => __(""),
  54.                         "type" => "textarea",
  55.                         "options" => array( "rows" => "5",
  56.                                             "cols" => "100") ),);
  57.  
  58. function mytheme_add_admin() {
  59.  
  60.     global $themename, $shortname, $options;
  61.  
  62.     if ( $_GET['page'] == basename(__FILE__) ) {
  63.  
  64.         if ( 'save' == $_REQUEST['action'] ) {
  65.  
  66.                 foreach ($options as $value) {
  67.                     update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }
  68.  
  69.                 foreach ($options as $value) {  
  70.                         if( $value['type'] == 'upload' )
  71.                         {  
  72.                             $overrides = array( 'test_form' => false);
  73.                             $upload = wp_handle_upload( $_FILES[ $value['id'] ], $overrides );
  74.                             if( isset( $upload['url'] ) )
  75.                             {
  76.                                 update_option( $value['id'], $upload['url'] );
  77.                             }
  78.                         }
  79.                         elseif( isset( $_REQUEST[ $value['id'] ] ) )
  80.                         {
  81.                             update_option( $value['id'], $_REQUEST[ $value['id'] ]  );
  82.                         }
  83.                     }
  84.  
  85.                 header("Location: admin.php?page=functions.php&saved=true");
  86.                 die;
  87.  
  88.         } else if( 'reset' == $_REQUEST['action'] ) {
  89.  
  90.             foreach ($options as $value) {
  91.                 delete_option( $value['id'] ); }
  92.  
  93.             header("Location: admin.php?page=functions.php&reset=true");
  94.             die;
  95.  
  96.         } else if ( 'reset_widgets' == $_REQUEST['action'] ) {
  97.             $null = null;
  98.             update_option('sidebars_widgets',$null);
  99.             header("Location: admin.php?page=functions.php&reset=true");
  100.             die;
  101.         }
  102.     }
  103.  
  104.     add_theme_page($themename." Options", "Tekilaz! Options", 'edit_themes', basename(__FILE__), 'mytheme_admin');
  105.  
  106. }
  107.  
  108. function mytheme_admin() {
  109.  
  110.     global $themename, $shortname, $options;
  111.  
  112.     if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' '.__('settings saved.','twentyten').'</strong></p></div>';
  113.     if ( $_REQUEST['reset'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' '.__('settings reset.','twentyten').'</strong></p></div>';
  114.     if ( $_REQUEST['reset_widgets'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' '.__('widgets reset.','twentyten').'</strong></p></div>';
  115. ?>
  116.  
  117. <div id="wrap">
  118.  
  119. <?php if ( function_exists('screen_icon') ) screen_icon(); ?>
  120.  
  121. <h2><?php echo $themename; ?> Options</h2>
  122.  
  123. <form method="post" action="" enctype="multipart/form-data">
  124.  
  125. <table class="form-table">
  126.  
  127. <?php foreach ($options as $value) {
  128.     switch ( $value['type'] ) {
  129.        
  130.         case 'text':
  131.         ?>
  132.         <tr valign="top">
  133.             <th scope="row"><label for="<?php echo $value['id']; ?>"><?php echo __($value['name'],'twentyten'); ?></label></th>
  134.             <td>
  135.                 <input name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_option( $value['id'] ) != "") { echo get_option( $value['id'] ); } else { echo $value['std']; } ?>" />
  136.                 <?php echo __($value['desc'],'twentyten'); ?>
  137.  
  138.             </td>
  139.         </tr>
  140.        
  141.         <?php
  142.         break;
  143.  
  144.         case 'textarea':
  145.         $ta_options = $value['options'];
  146.         ?>
  147.         <tr valign="top">
  148.             <th scope="row"><label for="<?php echo $value['id']; ?>"><?php echo __($value['name'],'twentyten'); ?></label></th>
  149.             <td><textarea name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" cols="<?php echo $ta_options['cols']; ?>" rows="<?php echo $ta_options['rows']; ?>"><?php
  150.                 if( get_option($value['id']) != "") {
  151.                         echo __(stripslashes(get_option($value['id'])),'twentyten');
  152.                     }else{
  153.                         echo __($value['std'],'twentyten');
  154.                 }?></textarea><br /><?php echo __($value['desc'],'twentyten'); ?></td>
  155.         </tr>
  156.         <?php
  157.         break;
  158.  
  159.         case 'nothing':
  160.         $ta_options = $value['options'];
  161.         ?>
  162.         </table>
  163.             <?php echo __($value['desc'],'twentyten'); ?>
  164.         <table class="form-table">
  165.        
  166.         <?php
  167.         break;
  168.        
  169.         case 'upload':
  170.         ?>
  171.         <tr>
  172.             <th>Imagen Actual:</th>
  173.             <td><?php if($img = get_option($value['id'])){ echo "<img src='$img'; />";}else{ echo "<i>Ninguna</i> ";} ?>  </td>
  174.         </tr>
  175.         <tr valign="top">
  176.                
  177.                 <th scope="row"><label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label></th>  
  178.                 <td><input type="file" name="<?php echo $value['id'] ?>" size="40" /><input type="hidden" name="<?php echo $value['id'] ?>" value="<?php if($img = get_option($value['id'])){ echo $img;} ?>" /> <i><?php echo __($value['desc'],'twentyten'); ?></i></td>
  179.         </tr>
  180.         <?php
  181.         break;
  182.        
  183.         default:
  184.  
  185.         break;
  186.     }
  187. }
  188. ?>
  189.  
  190.     </table>
  191. <table>
  192.     <tr>
  193.     <td><p class="submit">
  194.         <input name="save" type="submit" value="<?php _e('Save changes','twentyten'); ?>" />
  195.         <input type="hidden" name="action" value="save" />
  196.     </p>
  197.     <td>
  198. </form>
  199. <td>
  200. <form method="post" action="">
  201.     <p class="submit">
  202.         <input name="reset" type="submit" value="<?php _e('Reset','twentyten'); ?>" />
  203.         <input type="hidden" name="action" value="reset" />
  204.     </p>
  205. </form>
  206.     </td>
  207.     </tr>
  208. </table>
  209. <p>&copy; <a href="http://quick-flip.com/uTeli/">uTeli Theme.</a></p>
  210. </div>
  211. <?php
  212. }
  213.  
  214. add_action('admin_menu' , 'mytheme_add_admin');
  215.  
  216. /**
  217.  * TwentyTen functions and definitions
  218.  *
  219.  * Sets up the theme and provides some helper functions. Some helper functions
  220.  * are used in the theme as custom template tags. Others are attached to action and
  221.  * filter hooks in WordPress to change core functionality.
  222.  *
  223.  * The first function, twentyten_setup(), sets up the theme by registering support
  224.  * for various features in WordPress, such as post thumbnails, navigation menus, and the like.
  225.  *
  226.  * When using a child theme (see http://codex.wordpress.org/Theme_Development and
  227.  * http://codex.wordpress.org/Child_Themes), you can override certain functions
  228.  * (those wrapped in a function_exists() call) by defining them first in your child theme's
  229.  * functions.php file. The child theme's functions.php file is included before the parent
  230.  * theme's file, so the child theme functions would be used.
  231.  *
  232.  * Functions that are not pluggable (not wrapped in function_exists()) are instead attached
  233.  * to a filter or action hook. The hook can be removed by using remove_action() or
  234.  * remove_filter() and you can attach your own function to the hook.
  235.  *
  236.  * We can remove the parent theme's hook only after it is attached, which means we need to
  237.  * wait until setting up the child theme:
  238.  *
  239.  * <code>
  240.  * add_action( 'after_setup_theme', 'my_child_theme_setup' );
  241.  * function my_child_theme_setup() {
  242.  *     // We are providing our own filter for excerpt_length (or using the unfiltered value)
  243.  *     remove_filter( 'excerpt_length', 'twentyten_excerpt_length' );
  244.  *     ...
  245.  * }
  246.  * </code>
  247.  *
  248.  * For more information on hooks, actions, and filters, see http://codex.wordpress.org/Plugin_API.
  249.  *
  250.  * @package uTeli Theme
  251.  * @copyrights Temalia.net, EliasSierra.com, Quick-Flip.com
  252.  * @url http://uteli.temalia.net
  253.  */
  254.  
  255. /**
  256.  * Set the content width based on the theme's design and stylesheet.
  257.  *
  258.  * Used to set the width of images and content. Should be equal to the width the theme
  259.  * is designed for, generally via the style.css stylesheet.
  260.  */
  261. if ( ! isset( $content_width ) )
  262.     $content_width = 640;
  263.  
  264. /** Tell WordPress to run twentyten_setup() when the 'after_setup_theme' hook is run. */
  265. add_action( 'after_setup_theme', 'twentyten_setup' );
  266.  
  267. if ( ! function_exists( 'twentyten_setup' ) ):
  268. /**
  269.  * Sets up theme defaults and registers support for various WordPress features.
  270.  *
  271.  * Note that this function is hooked into the after_setup_theme hook, which runs
  272.  * before the init hook. The init hook is too late for some features, such as indicating
  273.  * support post thumbnails.
  274.  *
  275.  * To override twentyten_setup() in a child theme, add your own twentyten_setup to your child theme's
  276.  * functions.php file.
  277.  *
  278.  * @uses add_theme_support() To add support for post thumbnails and automatic feed links.
  279.  * @uses register_nav_menus() To add support for navigation menus.
  280.  * @uses add_custom_background() To add support for a custom background.
  281.  * @uses add_editor_style() To style the visual editor.
  282.  * @uses load_theme_textdomain() For translation/localization support.
  283.  * @uses add_custom_image_header() To add support for a custom header.
  284.  * @uses register_default_headers() To register the default custom header images provided with the theme.
  285.  * @uses set_post_thumbnail_size() To set a custom post thumbnail size.
  286.  *
  287.  * @since Twenty Ten 1.0
  288.  */
  289. function twentyten_setup() {
  290.  
  291.     // This theme styles the visual editor with editor-style.css to match the theme style.
  292.     add_editor_style();
  293.  
  294.     // Post Format support. You can also use the legacy "gallery" or "asides" (note the plural) categories.
  295.     add_theme_support( 'post-formats', array( 'aside', 'gallery', 'video', 'link', 'quote' ) );
  296.  
  297.     // This theme uses post thumbnails
  298.     add_theme_support( 'post-thumbnails' );
  299.  
  300.     // Add default posts and comments RSS feed links to head
  301.     add_theme_support( 'automatic-feed-links' );
  302.  
  303.     // Make theme available for translation
  304.     // Translations can be filed in the /languages/ directory
  305.     load_theme_textdomain( 'twentyten', TEMPLATEPATH . '/languages' );
  306.  
  307.     $locale = get_locale();
  308.     $locale_file = TEMPLATEPATH . "/languages/$locale.php";
  309.     if ( is_readable( $locale_file ) )
  310.         require_once( $locale_file );
  311.  
  312.     // This theme uses wp_nav_menu() in one location.
  313.     register_nav_menus( array(
  314.         'primary' => __( 'Menu Principal', 'twentyten' ),
  315.         'secondary' => __( 'Menu Footer', 'twentyten' ),
  316.     ) );
  317. }
  318. endif;
  319.  
  320. /**
  321.  * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
  322.  *
  323.  * To override this in a child theme, remove the filter and optionally add
  324.  * your own function tied to the wp_page_menu_args filter hook.
  325.  *
  326.  * @since Twenty Ten 1.0
  327.  */
  328. function twentyten_page_menu_args( $args ) {
  329.     $args['show_home'] = true;
  330.     return $args;
  331. }
  332. add_filter( 'wp_page_menu_args', 'twentyten_page_menu_args' );
  333.  
  334. /**
  335.  * Sets the post excerpt length to 40 characters.
  336.  *
  337.  * To override this length in a child theme, remove the filter and add your own
  338.  * function tied to the excerpt_length filter hook.
  339.  *
  340.  * @since Twenty Ten 1.0
  341.  * @return int
  342.  */
  343. function twentyten_excerpt_length( $length ) {
  344.     return 25;
  345. }
  346. add_filter( 'excerpt_length', 'twentyten_excerpt_length' );
  347.  
  348. /**
  349.  * Returns a "Continue Reading" link for excerpts
  350.  *
  351.  * @since Twenty Ten 1.0
  352.  * @return string "Continue Reading" link
  353.  */
  354. function twentyten_continue_reading_link() {
  355.     return ' <a href="'. get_permalink() . '">' . __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) . '</a>';
  356. }
  357.  
  358. /**
  359.  * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and twentyten_continue_reading_link().
  360.  *
  361.  * To override this in a child theme, remove the filter and add your own
  362.  * function tied to the excerpt_more filter hook.
  363.  *
  364.  * @since Twenty Ten 1.0
  365.  * @return string An ellipsis
  366.  
  367. function twentyten_auto_excerpt_more( $more ) {
  368.     return ' &hellip;' . twentyten_continue_reading_link();
  369. }
  370. add_filter( 'excerpt_more', 'twentyten_auto_excerpt_more' );
  371.  
  372. /**
  373.  * Adds a pretty "Continue Reading" link to custom post excerpts.
  374.  *
  375.  * To override this link in a child theme, remove the filter and add your own
  376.  * function tied to the get_the_excerpt filter hook.
  377.  *
  378.  * @since Twenty Ten 1.0
  379.  * @return string Excerpt with a pretty "Continue Reading" link
  380.  */
  381. function twentyten_custom_excerpt_more( $output ) {
  382.     if ( has_excerpt() && ! is_attachment() ) {
  383.         $output .= twentyten_continue_reading_link();
  384.     }
  385.     return $output;
  386. }
  387. add_filter( 'get_the_excerpt', 'twentyten_custom_excerpt_more' );
  388.  
  389. /**
  390.  * Remove inline styles printed when the gallery shortcode is used.
  391.  *
  392.  * Galleries are styled by the theme in Twenty Ten's style.css. This is just
  393.  * a simple filter call that tells WordPress to not use the default styles.
  394.  *
  395.  * @since Twenty Ten 1.2
  396.  */
  397. add_filter( 'use_default_gallery_style', '__return_false' );
  398.  
  399. /**
  400.  * Deprecated way to remove inline styles printed when the gallery shortcode is used.
  401.  *
  402.  * This function is no longer needed or used. Use the use_default_gallery_style
  403.  * filter instead, as seen above.
  404.  *
  405.  * @since Twenty Ten 1.0
  406.  * @deprecated Deprecated in Twenty Ten 1.2 for WordPress 3.1
  407.  *
  408.  * @return string The gallery style filter, with the styles themselves removed.
  409.  */
  410. function twentyten_remove_gallery_css( $css ) {
  411.     return preg_replace( "#<style type='text/css'>(.*?)</style>#s", '', $css );
  412. }
  413. // Backwards compatibility with WordPress 3.0.
  414. if ( version_compare( $GLOBALS['wp_version'], '3.1', '<' ) )
  415.     add_filter( 'gallery_style', 'twentyten_remove_gallery_css' );
  416.  
  417. if ( ! function_exists( 'twentyten_comment' ) ) :
  418. /**
  419.  * Template for comments and pingbacks.
  420.  *
  421.  * To override this walker in a child theme without modifying the comments template
  422.  * simply create your own twentyten_comment(), and that function will be used instead.
  423.  *
  424.  * Used as a callback by wp_list_comments() for displaying the comments.
  425.  *
  426.  * @since Twenty Ten 1.0
  427.  */
  428. function twentyten_comment( $comment, $args, $depth ) {
  429.     $GLOBALS['comment'] = $comment;
  430.     switch ( $comment->comment_type ) :
  431.         case '' :
  432.     ?>
  433.     <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
  434.         <div id="comment-<?php comment_ID(); ?>">
  435.         <div class="comment-author vcard">
  436.             <?php echo get_avatar( $comment, 40 ); ?>
  437.             <?php printf( __( '%s <span class="says">says:</span>', 'twentyten' ), sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?>
  438.         </div><!-- .comment-author .vcard -->
  439.         <?php if ( $comment->comment_approved == '0' ) : ?>
  440.             <em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'twentyten' ); ?></em>
  441.             <br />
  442.         <?php endif; ?>
  443.  
  444.         <div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
  445.             <?php
  446.                 /* translators: 1: date, 2: time */
  447.                 printf( __( '%1$s at %2$s', 'twentyten' ), get_comment_date(),  get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)', 'twentyten' ), ' ' );
  448.             ?>
  449.         </div><!-- .comment-meta .commentmetadata -->
  450.  
  451.         <div class="comment-body"><?php comment_text(); ?></div>
  452.  
  453.         <div class="reply">
  454.             <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
  455.         </div><!-- .reply -->
  456.     </div><!-- #comment-##  -->
  457.  
  458.     <?php
  459.             break;
  460.         case 'pingback'  :
  461.         case 'trackback' :
  462.     ?>
  463.     <li class="post pingback">
  464.         <p><?php _e( 'Pingback:', 'twentyten' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( '(Edit)', 'twentyten' ), ' ' ); ?></p>
  465.     <?php
  466.             break;
  467.     endswitch;
  468. }
  469. endif;
  470.  
  471. /**
  472.  * Register widgetized areas, including two sidebars and four widget-ready columns in the footer.
  473.  *
  474.  * To override twentyten_widgets_init() in a child theme, remove the action hook and add your own
  475.  * function tied to the init hook.
  476.  *
  477.  * @since Twenty Ten 1.0
  478.  * @uses register_sidebar
  479.  */
  480. function twentyten_widgets_init() {
  481.     // Area 1, located at the top of the sidebar.
  482.     register_sidebar( array(
  483.         'name' => __( 'Primary Widget Area', 'twentyten' ),
  484.         'id' => 'primary-widget-area',
  485.         'description' => __( 'The primary widget area', 'twentyten' ),
  486.         'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  487.         'after_widget' => '</li>',
  488.         'before_title' => '<h3 class="widget-title">',
  489.         'after_title' => '</h3>',
  490.     ) );
  491.  
  492.     // Area 2, located below the Primary Widget Area in the sidebar. Empty by default.
  493.     register_sidebar( array(
  494.         'name' => __( 'Secondary Widget Area', 'twentyten' ),
  495.         'id' => 'secondary-widget-area',
  496.         'description' => __( 'The secondary widget area', 'twentyten' ),
  497.         'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  498.         'after_widget' => '</li>',
  499.         'before_title' => '<h3 class="widget-title">',
  500.         'after_title' => '</h3>',
  501.     ) );
  502.  
  503.     // Area 3, located in the footer. Empty by default.
  504.     register_sidebar( array(
  505.         'name' => __( 'First Footer Widget Area', 'twentyten' ),
  506.         'id' => 'first-footer-widget-area',
  507.         'description' => __( 'The first footer widget area', 'twentyten' ),
  508.         'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  509.         'after_widget' => '</li>',
  510.         'before_title' => '<h3 class="widget-title">',
  511.         'after_title' => '</h3>',
  512.     ) );
  513.  
  514.     // Area 4, located in the footer. Empty by default.
  515.     register_sidebar( array(
  516.         'name' => __( 'Second Footer Widget Area', 'twentyten' ),
  517.         'id' => 'second-footer-widget-area',
  518.         'description' => __( 'The second footer widget area', 'twentyten' ),
  519.         'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  520.         'after_widget' => '</li>',
  521.         'before_title' => '<h3 class="widget-title">',
  522.         'after_title' => '</h3>',
  523.     ) );
  524.  
  525.     // Area 5, located in the footer. Empty by default.
  526.     register_sidebar( array(
  527.         'name' => __( 'Third Footer Widget Area', 'twentyten' ),
  528.         'id' => 'third-footer-widget-area',
  529.         'description' => __( 'The third footer widget area', 'twentyten' ),
  530.         'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  531.         'after_widget' => '</li>',
  532.         'before_title' => '<h3 class="widget-title">',
  533.         'after_title' => '</h3>',
  534.     ) );
  535.  
  536.     // Area 6, located in the footer. Empty by default.
  537.     register_sidebar( array(
  538.         'name' => __( 'Fourth Footer Widget Area', 'twentyten' ),
  539.         'id' => 'fourth-footer-widget-area',
  540.         'description' => __( 'The fourth footer widget area', 'twentyten' ),
  541.         'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
  542.         'after_widget' => '</li>',
  543.         'before_title' => '<h3 class="widget-title">',
  544.         'after_title' => '</h3>',
  545.     ) );
  546. }
  547.  
  548. /** Area de Registro en Tekilaz Media
  549.  *
  550.  */
  551.  
  552.     function display_message( $message = false )
  553. {
  554.  if( is_wp_error( $message ) )
  555.  {
  556.   echo '<p>' . $message->get_error_message() . '</p>';    
  557.  }
  558. }
  559.  
  560. function add_new_user($username, $password, $confirm, $email, $nombre, $apellido)
  561. {
  562.  require ( ABSPATH . WPINC . '/registration.php' );
  563.          
  564.  // Remove html tags from the title and content fields
  565.  $username_stripped = strip_tags($username);
  566.  $password_stripped = strip_tags($password);
  567.  $confirm_stripped = strip_tags($confirm);
  568.  $email_stripped = strip_tags($email);
  569.  $nombre_stripped = strip_tags($nombre);
  570.  $apellido_stripped = strip_tags($apellido);
  571.      
  572.  // Check to see if User Registration is turned OFF
  573.  if (get_option('users_can_register') == '0') return new WP_Error('reg_off', 'Lo sentimos, los registros están desactivados');
  574.  // Validate the Form Data
  575.  if(isEmptyString($nombre_stripped)) return new WP_Error('forgot_nombre', 'Por favor ingresa tu Nombre');
  576.  if(isEmptyString($apellido_stripped)) return new WP_Error('forgot_apellido', 'Por favor ingresa tu Apellido');
  577.  if(isEmptyString($username_stripped)) return new WP_Error('forgot_username', 'Por favor ingresa un Nombre de Usuario');
  578.  if(strlen($username_stripped)<6) return new WP_Error('username_corto', 'El Nombre de Usuario debe tener 6 caracteres como mínimo');
  579.  if(username_exists($username_stripped)) return new WP_Error('username_exists', 'Lo sentimos, ese Nombre de Usuario ya existe');
  580.  if(!is_email($email_stripped)) return new WP_Error('verify_email', 'Por favor ingresa un Correo Electrónico valido');
  581.  if(email_exists($email_stripped)) return new WP_Error('email_exists', 'Lo sentimos, ese Correo Electrónico ya esta siendo usado por otro usuario');
  582.  if(isEmptyString($password_stripped)) return new WP_Error('forgot_password', 'Por favor ingresa una Contraseña');
  583.  if(strlen($password_stripped)<6) return new WP_Error('password_corto', 'La Contraseña debe tener por lo menos 6 caracteres');
  584.  if($password_stripped != $confirm_stripped) return new WP_Error('passwords_no_match', 'Tu Contraseña no concuerda');
  585.  
  586.  // Create the user
  587.  $user_data = array
  588.  (
  589.     'first_name' => $nombre_stripped,
  590.     'last_name' => $apellido_stripped,
  591.     'user_login' => $username_stripped,
  592.     'user_pass' => $password_stripped,
  593.     'user_email' => $email_stripped,
  594.  );
  595.  $user_id = wp_insert_user($user_data);
  596.  $user = get_userdata($user_id);
  597.      
  598.  // Log the User In
  599.  wp_login($username_stripped, $password_stripped);
  600.  wp_clearcookie();
  601.  wp_setcookie($username_stripped, $remember, false);
  602.      
  603.  // Email User with Login Info
  604.  $site = get_bloginfo("name");
  605.  $sitename = str_replace("&amp;", "&", $site);
  606.  
  607.  $headers = 'From: '.$sitename.' <noreply@'.$sitename.'>' . "\r\n";
  608.  $to = $user->user_email;
  609.  $subject = sprintf(__('Ya tienes cuenta en %s - ¡Bienvenido!'), $sitename) . "\r\n\r\n";
  610.  $message = sprintf(__('Estimado %s:'), $user->user_login) . "\r\n\r\n";
  611.  $message .= sprintf(__('Gracias por registrarte a %s la Comunidad en la que podrás dar a conocer Tus Propias Opiniones de todos los Productos y Servicios que hayas Comprado o Usado.'), $sitename) . "\r\n\r\n";
  612.  $message .= sprintf(__('-------------------------------------------------------------------------------------')). "\r\n\r\n";
  613.  $message .= sprintf(__('Te recordamos tus datos:)')). "\r\n\r\n";
  614.  $message .= sprintf(__('Nombre de Usuario: %s'), $user->user_login) . "\r\n\r\n";
  615.  $message .= sprintf(__('Contraseña: %s'), $password_stripped) . "\r\n\r\n";
  616.  $message .= sprintf(__('-------------------------------------------------------------------------------------')). "\r\n\r\n";
  617.  $message .= sprintf(__('Una vez más, ¡bienvenido!')) . "\r\n\r\n";
  618.  $message .= sprintf(__('Equipo de %s'), $sitename) . "\r\n\r\n";
  619.  
  620.  wp_mail($to, $subject, $message, $headers);
  621.  // Redirect the User to My Account
  622.  redirect_to_myaccount_url();
  623. }  
  624.  
  625. function isEmptyString($data)
  626. {
  627.  return (trim($data) === "" or $data === null);
  628. }
  629.  
  630. function redirect_to_myaccount_url()
  631. {
  632.  wp_redirect(get_bloginfo('url') . '/panel/');
  633. }
  634.  
  635. // Log In User
  636. function log_in_user($username, $password)
  637. {
  638.  // Get the user based on the username from the POST
  639.  $user = parse_user($username);
  640.  // Remove html tags from the title and content fields
  641.  $username_stripped = strip_tags($username);
  642.  $password_stripped = strip_tags($password);
  643.  
  644.  // Validate the Form Data
  645.  if(isEmptyString($username_stripped)) return new WP_Error('forgot_username', 'Por favor ingresa un Nombre de Usuario');
  646.  if(isEmptyString($password_stripped)) return new WP_Error('incorrect_password', 'Por favor ingresa una Contraseña');
  647.  if(!wp_check_password( $password_stripped, $user->user_pass ) ) return new WP_Error('incorrect_password', 'Ingresaste una Contraseña incorrecta');
  648.      
  649.  wp_set_auth_cookie($user->ID, $remember);
  650.  wp_login($username_stripped, $password_stripped);
  651.          
  652.  redirect_to_myaccount_url();
  653. }  
  654.  
  655. /** Register sidebars by running twentyten_widgets_init() on the widgets_init hook. */
  656. add_action( 'widgets_init', 'twentyten_widgets_init' );
  657.  
  658. /**
  659.  * Removes the default styles that are packaged with the Recent Comments widget.
  660.  *
  661.  * To override this in a child theme, remove the filter and optionally add your own
  662.  * function tied to the widgets_init action hook.
  663.  *
  664.  * This function uses a filter (show_recent_comments_widget_style) new in WordPress 3.1
  665.  * to remove the default style. Using Twenty Ten 1.2 in WordPress 3.0 will show the styles,
  666.  * but they won't have any effect on the widget in default Twenty Ten styling.
  667.  *
  668.  * @since Twenty Ten 1.0
  669.  */
  670. function twentyten_remove_recent_comments_style() {
  671.     add_filter( 'show_recent_comments_widget_style', '__return_false' );
  672. }
  673. add_action( 'widgets_init', 'twentyten_remove_recent_comments_style' );
  674.  
  675. if ( ! function_exists( 'twentyten_posted_on' ) ) :
  676. /**
  677.  * Prints HTML with meta information for the current post-date/time and author.
  678.  *
  679.  * @since Twenty Ten 1.0
  680.  */
  681. function twentyten_posted_on() {
  682.     printf( __( '<span class="%1$s">Posted on</span> %2$s <span class="meta-sep">by</span> %3$s', 'twentyten' ),
  683.         'meta-prep meta-prep-author',
  684.         sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a>',
  685.             get_permalink(),
  686.             esc_attr( get_the_time() ),
  687.             get_the_date()
  688.         ),
  689.         sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
  690.             get_author_posts_url( get_the_author_meta( 'ID' ) ),
  691.             sprintf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ),
  692.             get_the_author()
  693.         )
  694.     );
  695. }
  696. endif;
  697.  
  698. if ( ! function_exists( 'twentyten_posted_in' ) ) :
  699. /**
  700.  * Prints HTML with meta information for the current post (category, tags and permalink).
  701.  *
  702.  * @since Twenty Ten 1.0
  703.  */
  704. function twentyten_posted_in() {
  705.     // Retrieves tag list of current post, separated by commas.
  706.     $tag_list = get_the_tag_list( '', ', ' );
  707.     if ( $tag_list ) {
  708.         $posted_in = __( 'This entry was posted in %1$s and tagged %2$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
  709.     } elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
  710.         $posted_in = __( 'This entry was posted in %1$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
  711.     } else {
  712.         $posted_in = __( 'Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten' );
  713.     }
  714.     // Prints the string, replacing the placeholders.
  715.     printf(
  716.         $posted_in,
  717.         get_the_category_list( ', ' ),
  718.         $tag_list,
  719.         get_permalink(),
  720.         the_title_attribute( 'echo=0' )
  721.     );
  722. }
  723. endif;
  724. // Get all custom fields attached to a page
  725. if( !function_exists('base_get_all_custom_fields') ) {
  726.     function base_get_all_custom_fields(){
  727.         global $post;
  728.         global $wpdb;
  729.         $sql = "SELECT * FROM $wpdb->postmeta   WHERE post_id = $post->ID ORDER BY meta_id ASC";
  730.         $custom_fields = $wpdb->get_results($sql);
  731.         $custom_field_array = array();
  732.         foreach($custom_fields as $field) {
  733.             $custom_field_array["$field->meta_key"] = $field->meta_value;
  734.         }
  735.         return $custom_field_array;
  736.     }
  737. }
  738.  
  739. function addUploadMimes($mimes) {
  740.     $mimes = array_merge($mimes, array(
  741.         'srt|tmbundle|tmCommand|tmDragCommand|tmSnippet|tmLanguage|tmPreferences' => 'application/octet-stream'
  742.     ));
  743.  
  744.     return $mimes;
  745. }
  746.  
  747. add_filter('upload_mimes', 'addUploadMimes');
  748.  
  749. function atom_search_where($where){
  750.   global $wpdb;
  751.   if (is_search())
  752.     $where .= "OR (t.name LIKE '%".get_search_query()."%' AND {$wpdb->posts}.post_status = 'publish')";
  753.   return $where;
  754. }
  755.  
  756. function atom_search_join($join){
  757.   global $wpdb;
  758.   if (is_search())
  759.     $join .= "LEFT JOIN {$wpdb->term_relationships} tr ON {$wpdb->posts}.ID = tr.object_id INNER JOIN {$wpdb->term_taxonomy} tt ON tt.term_taxonomy_id=tr.term_taxonomy_id INNER JOIN {$wpdb->terms} t ON t.term_id = tt.term_id";
  760.   return $join;
  761. }
  762.  
  763. function atom_search_groupby($groupby){
  764.   global $wpdb;
  765.  
  766.   // we need to group on post ID
  767.   $groupby_id = "{$wpdb->posts}.ID";
  768.   if(!is_search() || strpos($groupby, $groupby_id) !== false) return $groupby;
  769.  
  770.   // groupby was empty, use ours
  771.   if(!strlen(trim($groupby))) return $groupby_id;
  772.  
  773.   // wasn't empty, append ours
  774.   return $groupby.", ".$groupby_id;
  775. }
  776.  
  777. add_filter('posts_where','atom_search_where');
  778. add_filter('posts_join', 'atom_search_join');
  779. add_filter('posts_groupby', 'atom_search_groupby');
  780.  
  781. function new_excerpt_length($length) {
  782. return 35;
  783. }
  784. add_filter('excerpt_length', 'new_excerpt_length');
  785.  
  786.  
  787.  
  788. // -------------------------------- prev next functions
  789.  
  790. function get_the_subcategory()
  791. {
  792.     $categories = get_the_category();
  793.  
  794.     // get the sub category if we have them
  795.     foreach ($categories as $cat)
  796.     {
  797.         $parent = $cat->category_parent;
  798.  
  799.         if ($parent != 0 )
  800.         {
  801.         $sub_cat_ID = $cat->cat_ID;
  802.         }
  803.     }
  804.  
  805.     if (!$sub_cat_ID)
  806.     {
  807.     return false;
  808.     }
  809.     else
  810.     {
  811.     return $sub_cat_ID;
  812.     }
  813. }
  814.  
  815.  
  816. function transformar($link_iframe){
  817.     $src = explode("?",$link_iframe,2);
  818.     $params = explode("&",$src[1]);
  819.     for ( $i = 0; $i < count($params); $i++) {
  820.         $param = explode("=",$params[$i],2);
  821.         if ( $param[0] != 'id' && $param[0] != 'sub' && $param[0] != 'sub_pre' ){
  822.             $param[1] = encriptar($param[1]);
  823.             $params[$i] = $param[0].'='.$param[1];
  824.         }
  825.     }
  826.     $src[1]=implode("&",$params);
  827.     return $src[0]."?".$src[1];
  828.     }
  829.    
  830. function encriptar( $info_a_encriptar) {
  831.     $abc1 = "abcdefghijklmnopqrstuvwxyz01234ABCDEFGHIJKLMNOPQRSTUVWXYZ56789";
  832.     $len_abc = strlen($abc1);
  833.     $info_encriptada = "";
  834.     $cambio = false;
  835.     for ($i = 0; $i < strlen($info_a_encriptar); $i++) {
  836.         for ($j = 0; $j < $len_abc; $j++) {
  837.             if ($info_a_encriptar[$i] == $abc1[$j] ){
  838.                 $cambio = true;
  839.                 if ( $j > $len_abc - 4 ) {
  840.                     $info_encriptada = $info_encriptada.$abc1[$j - ( $len_abc - 3 )];
  841.                 } else {
  842.                     $info_encriptada = $info_encriptada.$abc1[$j + 3];
  843.                 }
  844.                 $j = $len_abc;
  845.             }
  846.         }
  847.         if (!$cambio) {
  848.             $info_encriptada = $info_encriptada.$info_a_encriptar[$i];
  849.         }
  850.         $cambio = false;
  851.     }
  852.     $info_a_encriptar = $info_encriptada;
  853.     return $info_a_encriptar;
  854.     }
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861. function get_next_subcategory_post_link()
  862. {
  863.  
  864. $category = get_the_category(2216);
  865.  
  866. $cat_ID = 2217;
  867.  
  868. if($cat_ID != false)
  869. {
  870.     $args = array(
  871.     ‘numberposts’     => 1000,
  872.     ‘category’        => $cat_ID,
  873.     ‘orderby’         => ‘post_date’,
  874.     ‘order’           => ‘ASC’ );
  875.  
  876.     $list = get_posts($args);
  877.     ?>
  878.     <textarea>
  879.     <?php print_r  ($list); ?>
  880.     </textarea>
  881.     <?
  882.     $current = false;
  883.  
  884.     foreach($list as $post)
  885.     {
  886.         if($current == true)
  887.         {
  888.         return get_permalink($post->ID);
  889.         }
  890.  
  891.         if($post->ID == get_the_ID())
  892.         {
  893.        
  894.         $current = true;
  895.         }
  896.         else
  897.         {
  898.         }
  899.     }
  900. }
  901. else
  902. {
  903. return '#error';
  904. }
  905. }
  906.  
  907.  
  908. function get_previous_subcategory_post_link()
  909. {
  910. $cat_ID = get_the_subcategory();
  911. $args = array(
  912. ‘numberposts’     => 1000,
  913. ‘category’        => $cat_ID,
  914. ‘orderby’         => ‘post_date’,
  915. ‘order’           => ‘DESC’ );
  916.  
  917. $list = get_posts($args);
  918.  
  919. $current = false;
  920.  
  921. foreach($list as $post)
  922. {
  923. if($current == true)
  924. {
  925. return get_permalink($post->ID);
  926. }
  927.  
  928. if($post->ID == get_the_ID())
  929. {
  930. $current = true;
  931. }
  932. else
  933. {
  934. }
  935. }
  936. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement