S
Simi
Gamma
Social Media
¡Usuario con pocos negocios! ¡Utiliza siempre saldo de Forobeta!
Buenas noches compañeros, veran estoy usando un Theme para wp pero estoy teniendo problemas con la seccion de videos en la que me sale este mensaje:
cuando sigo la ruta el codigo en la linea 253 es este:
la verdad en php estoy perdido... espero me puedan ayudar ... desde ya muchas gracias, les dejo la hoja de codigos completos por si lo quieren ver todo (la linea en cuestion esta marcada de rojo):
Insertar CODE, HTML o PHP:
Warning: file_get_contents() [function.file-get-contents]: Couldn't resolve host name in /home/co/public_html/wp-content/themes/wpviral/functions.php on line 253
Warning: file_get_contents(http://urls.api.twitter.com/1/urls/count.json?url=http://***/videos/vegeta-se-solidariza-con-ecuador-en-emotivo-video/) [function.file-get-contents]: failed to open stream: operation failed in /home/co/public_html/wp-content/themes/wpviral/functions.php on line 253
cuando sigo la ruta el codigo en la linea 253 es este:
Insertar CODE, HTML o PHP:
$json_string = file_get_contents('http://urls.api.twitter.com/1/urls/count.json?url=' . $url);
la verdad en php estoy perdido... espero me puedan ayudar ... desde ya muchas gracias, les dejo la hoja de codigos completos por si lo quieren ver todo (la linea en cuestion esta marcada de rojo):
Insertar CODE, HTML o PHP:
<?php
define( 'EDD_SL_STORE_URL', 'https://mundothemes.com' ); /*IMPORTANTE: no modifique esta linea el theme podria dejar de funcionar correctamente*/
define( 'EDD_SL_THEME_NAME', 'wpviral' ); /*IMPORTANTE: no modifique esta linea el theme podria dejar de funcionar correctamente*/
if ( !class_exists( 'EDD_SL_Theme_Updater' ) ) {
include( dirname( __FILE__ ) . '/actualizar.php' );
}
function edd_sl_sample_theme_updater() {
$test_license = trim( get_option( 'edd_sample_theme_license_key' ) );
$edd_updater = new EDD_SL_Theme_Updater( array(
'remote_api_url' => EDD_SL_STORE_URL,
'version' => '1.5.2', /* enviado el 01/11/2014 a las 19:00 horas */
'license' => $test_license,
'item_name' => EDD_SL_THEME_NAME,
'author' => 'Mundothemes') ); /*IMPORTANTE: no modifique esta linea el theme podria dejar de funcionar correctamente*/
}
// Deshabilitar admin top bar
add_filter( 'show_admin_bar', '__return_false' );
// Incluyendo el framework
include_once 'includes/framework/options-init.php';
// Tamaños de las imagenes
function imagenes_size() {
add_theme_support( 'post-thumbnails' );
add_image_size('home', 500, 0, true);
add_image_size('sidebar', 300, 160, true);
}
add_action('after_setup_theme', 'imagenes_size');
// Registro de menu
function register_my_menu() {
register_nav_menu('top_menu',__( 'Menu del Header' ));
}
add_action( 'init', 'register_my_menu' );
// paginador
function pagination($pages = '', $range = 2) {
$showitems = ($range * 2)+1;
global $paged; if(empty($paged)) $paged = 1;
if($pages == '') {
global $wp_query; $pages = $wp_query->max_num_pages;
if(!$pages){ $pages = 1; }
}
if(1 != $pages) {
echo "<div class='paginador'>";
if($paged > 2 && $paged > $range+1 && $showitems < $pages)
echo "<a class=previouspostslink' rel='nofollow' href='".get_pagenum_link(1)."'>« Primera</a>";
if($paged > 1 && $showitems < $pages)
echo "<a class=previouspostslink' rel='nofollow' href='".get_pagenum_link($paged - 1)."'>‹ Anterior</a>";
for ($i=1; $i <= $pages; $i++){
if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems )) {
echo ($paged == $i)? "<span class='current'>".$i."</span>":"<a rel='nofollow' class='page larger' href='".get_pagenum_link($i)."'>".$i."</a>";
}
}
if ($paged < $pages && $showitems < $pages)
echo "<a rel='nofollow' class=previouspostslink' href='".get_pagenum_link($paged + 1)."'>Siguiente ›</a>";
if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages)
echo "<a rel='nofollow' class=previouspostslink' href='".get_pagenum_link($pages)."'>Ultima »</a>";
echo "</div>";
}
}
// Cargando las imagenes a Wordpress.
function insert_attachment($file_handler,$post_id,$setthumb='false') {
if ($_FILES[$file_handler]['error'] !== UPLOAD_ERR_OK){ return __return_false();
}
require_once(ABSPATH . "wp-admin" . '/includes/image.php');
require_once(ABSPATH . "wp-admin" . '/includes/file.php');
require_once(ABSPATH . "wp-admin" . '/includes/media.php');
echo $attach_id = media_handle_upload( $file_handler, $post_id );
if ($setthumb == 1) update_post_meta($post_id,'_thumbnail_id',$attach_id);
return $attach_id;
}
// Post_type Vieos //
$category_args = apply_filters( 'edd_videos_category_args', array(
'hierarchical' => true,
'labels' => apply_filters('edd_videos_category_labels', $category_labels),
'show_ui' => true,
'query_var' => 'videos_category',
'rewrite' => array('slug' => $slug . '/category', 'with_front' => false, 'hierarchical' => true ),
'capabilities' => array( 'manage_terms' => 'manage_product_terms','edit_terms' => 'edit_product_terms','assign_terms' => 'assign_product_terms','delete_terms' => 'delete_product_terms' )
)
);
register_taxonomy( 'videos_category', array('videos'), $category_args );
register_taxonomy_for_object_type( 'videos_category', 'videos' );
function videos() {
$labels = array(
'name' => _x( 'Videos', 'Post Type General Name', 'noticias' ),
'singular_name' => _x( 'Video', 'Post Type Singular Name', 'noticias' ),
'menu_name' => __( 'Videos', 'videos' ),
'parent_item_colon' => __( 'Parent Item:', 'videos' ),
'all_items' => __( 'Todos los videos', 'videos' ),
'view_item' => __( 'Ver video', 'videos' ),
'add_new_item' => __( 'Agregar Video', 'videos' ),
'add_new' => __( 'Agregar nuevo', 'videos' ),
'edit_item' => __( 'Editar', 'videos' ),
'update_item' => __( 'Actualizar', 'videos' ),
'search_items' => __( 'Buscar', 'videos' ),
'not_found' => __( 'No se encontro', 'videos' ),
'not_found_in_trash' => __( 'No se encontro en la pelera', 'videos' ),
);
$rewrite = array(
'slug' => 'videos',
'with_front' => true,
'pages' => true,
'feeds' => true,
);
$args = array(
'label' => __( 'videos', 'videos' ),
'description' => __( 'Agregar Videos', 'videos' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'trackbacks', 'revisions', 'custom-fields', 'page-attributes', 'post-formats', ),
'taxonomies' => array( 'category', 'post_tag' ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => false,
'show_in_admin_bar' => true,
'menu_position' => 5,
'menu_icon' => get_bloginfo('template_directory') .'/images/videos.png',
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'rewrite' => $rewrite,
'capability_type' => 'page',
);
register_post_type( 'videos', $args );
}
add_action( 'init', 'videos', 0 );
//// #################################################### /////
$sp_boxes = array (
'ID de Youtube (opcional)' => array (
array( 'idyt', 'ID video de Youtube' ),
),
'Embed Video' => array (
array( 'embed', 'Codigo embed del video:', 'textarea' ),
),
'Duracion del video' => array (
array( 'duracion', 'Duracion del video' ),
),
);
add_action( 'admin_menu', 'sp_add_custom_box' );
add_action( 'save_post', 'sp_save_postdata', 1, 2 );
function sp_add_custom_box() {
global $sp_boxes;
if ( function_exists( 'add_meta_box' ) ) {
foreach ( array_keys( $sp_boxes ) as $box_name ) {
add_meta_box( $box_name, __( $box_name, 'sp' ), 'sp_post_custom_box', 'videos', 'normal', 'high' );
}
}
}
function sp_post_custom_box ( $obj, $box ) {
global $sp_boxes;
static $sp_nonce_flag = false;
if ( ! $sp_nonce_flag ) {
echo_sp_nonce();
$sp_nonce_flag = true;
}
foreach ( $sp_boxes[$box['id']] as $sp_box ) {
echo field_html( $sp_box );
}
}
function field_html ( $args ) {
switch ( $args[2] ) {
case 'textarea':
return text_area( $args );
case 'checkbox':
case 'radio':
case 'text':
case 'submit':
default:
return text_field( $args );
}
}
function text_field ( $args ) {
global $post;
// adjust data
$args[2] = get_post_meta($post->ID, $args[0], true);
$args[1] = __($args[1], 'sp' );
$label_format =
'<label for="%1$s">%2$s</label><br />'
. '<input style="width: 95%%;" type="text" name="%1$s" value="%3$s" /><br /><br />';
return vsprintf( $label_format, $args );
}
function text_area ( $args ) {
global $post;
// adjust data
$args[2] = get_post_meta($post->ID, $args[0], true);
$args[1] = __($args[1], 'sp' );
$label_format =
'<label for="%1$s">%2$s</label><br />'
. '<textarea style="width: 95%%;" name="%1$s">%3$s</textarea><br /><br />';
return vsprintf( $label_format, $args );
}
function sp_save_postdata($post_id, $post) {
global $sp_boxes;
if ( ! wp_verify_nonce( $_POST['sp_nonce_name'], 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;
}
foreach ( $sp_boxes as $sp_box ) {
foreach ( $sp_box as $sp_fields ) {
$my_data[$sp_fields[0]] = $_POST[$sp_fields[0]];
}
}
foreach ($my_data as $key => $value) {
if ( 'revision' == $post->post_type ) {
return;
}
$value = implode(',', (array)$value);
if ( get_post_meta($post->ID, $key, FALSE) ) {
update_post_meta($post->ID, $key, $value);
} else {
add_post_meta($post->ID, $key, $value);
}
if (!$value) {
delete_post_meta($post->ID, $key);
}
}
}
function echo_sp_nonce () {
echo sprintf(
'<input type="hidden" name="%1$s" id="%1$s" value="%2$s" />',
'sp_nonce_name',
wp_create_nonce( plugin_basename(__FILE__) )
);
}
if ( !function_exists('get_custom_field') ) {
function get_custom_field($field) {
global $post;
$custom_field = get_post_meta($post->ID, $field, true);
echo $custom_field;
}
}
function get_likes($url) {
$json_string = file_get_contents('http://graph.facebook.com/?ids=' . $url);
$json = json_decode($json_string, true);
return intval( $json[$url]['shares'] );
}
function get_tweets($url) {
[COLOR="#FF0000"] $json_string = file_get_contents('http://urls.api.twitter.com/1/urls/count.json?url=' . $url);
$json = json_decode($json_string, true);[/COLOR]
return intval( $json['count'] );
}
function get_plusones($url) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://clients6.google.com/rpc");
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, '[{"method":"pos.plusones.get","id":"p","params":{"nolog":true,"id":"' . $url . '","source":"widget","userId":"@viewer","groupId":"@self"},"jsonrpc":"2.0","key":"p","apiVersion":"v1"}]');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
$curl_results = curl_exec ($curl);
curl_close ($curl);
$json = json_decode($curl_results, true);
return intval( $json[0]['result']['metadata']['globalCounts']['count'] );
}
function seo_wpViral() {
global $page, $paged, $post;
$output = '';
if (is_category() || is_tag()) {
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
if ($paged > 1) {
$output .= "" . '<meta name="robots" content="noindex,follow">' . "\n";
} else {
$output .= "" . '<meta name="robots" content="index,follow">' . "\n";
}
} else if (is_home() || is_singular()) {
$output .= "" . '<meta name="robots" content="index,follow">' . "\n";
} else {
$output .= "" . '<meta name="robots" content="noindex,follow">' . "\n";
}
$seo_desc = get_post_meta($post->ID, 'mm_seo_desc', true);
$description = get_bloginfo('description', 'display');
$pagedata = get_post($post->ID);
if (is_singular()) {
if (!empty($seo_desc)) {
$content = $seo_desc;
} else if (!empty($pagedata)) {
$content = apply_filters('the_excerpt_rss', $pagedata->post_content);
$content = substr(trim(strip_tags($content)), 0, 156);
$content = preg_replace('#\n#', ' ', $content);
$content = preg_replace('#\s{2,}#', ' ', $content);
$content = trim($content);
}
} else {
$content = $description;
}
$output .= '<meta name="description" content="' . esc_attr($content) . '" />' . "\n";
$seo_desc = get_post_meta($post->ID, 'mm_seo_desc', true);
$description = get_bloginfo('description', 'display');
$pagedata = get_post($post->ID);
if (is_singular()) {
if (!empty($seo_desc)) {
$content = $seo_desc;
} else if (!empty($pagedata)) {
$content = apply_filters('the_excerpt_rss', $pagedata->post_content);
$content = substr(trim(strip_tags($content)), 0, 500);
$content = preg_replace('#\n#', ' ', $content);
$content = preg_replace('#\s{2,}#', ' ', $content);
$content = trim($content);
}
} else {
$content = $description;
}
$output .= '<meta property="og:description" content="' . esc_attr($content) . '" />' . "\n";
return $output;
}
add_filter( 'pre_get_posts', 'my_get_posts' );
function my_get_posts( $query ) {
if ( is_home() && false == $query->query_vars['suppress_filters'] )
$query->set( 'post_type', array(
'post', 'videos' ) );
return $query;
}
/*************************************************************************************************/
add_action( 'admin_init', 'edd_sl_sample_theme_updater' );
function edd_sample_theme_license_menu() {
add_menu_page( 'Munodthemes Licencia', 'Mundothemes', 'manage_options', 'mundothemes', 'edd_sample_theme_license_page',get_stylesheet_directory_uri()."/" . 'images/key.png');
}
add_action('admin_menu', 'edd_sample_theme_license_menu');
function edd_sample_theme_license_page() {
$license = get_option( 'edd_sample_theme_license_key' );
$status = get_option( 'edd_sample_theme_license_key_status' );
?>
<div class="wrap">
<h2><?php _e('Theme License Options', 'mundothemes'); ?></h2>
<form method="post" action="options.php">
<?php settings_fields('edd_sample_theme_license'); ?>
<table class="form-table">
<tbody>
<tr valign="top">
<th scope="row" valign="top">
<?php _e('License Key','mundothemes'); ?>
</th>
<td>
<input id="edd_sample_theme_license_key" name="edd_sample_theme_license_key" type="text" class="regular-text" value="<?php echo esc_attr( $license ); ?>" />
<label class="description" for="edd_sample_theme_license_key"><?php _e('Enter your license key','mundothemes'); ?></label>
</td>
</tr>
<?php if( false !== $license ) { ?>
<tr valign="top">
<th scope="row" valign="top">
<?php _e('Activate License', 'mundothemes'); ?>
</th>
<td>
<?php if( $status !== false && $status == 'valid' ) { ?>
<span style="color: green;padding: 5px;float: left;font-weight: bold;"><?php _e('active','mundothemes'); ?></span>
<?php wp_nonce_field( 'edd_sample_nonce', 'edd_sample_nonce' ); ?>
<input type="submit" class="button-secondary" name="edd_theme_license_deactivate" value="<?php _e('Deactivate License','mundothemes'); ?>"/>
<span style="color: #516EC8;padding: 5px;float: left;font-weight: bold;"><?php echo $_SERVER['HTTP_HOST']; ?></span>
<?php } else { wp_nonce_field( 'edd_sample_nonce', 'edd_sample_nonce' ); ?>
<span style="color: red;padding: 5px;float: left;font-weight: bold;">ERROR</span>
<input type="submit" class="button-secondary" name="edd_theme_license_activate" value="<?php _e('Activate License','mundothemes'); ?>"/>
<?php } ?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<?php submit_button(); ?>
</form>
<?php
}
function edd_sample_theme_register_option() {
register_setting('edd_sample_theme_license', 'edd_sample_theme_license_key', 'edd_theme_sanitize_license' );
}
add_action('admin_init', 'edd_sample_theme_register_option');
function edd_theme_sanitize_license( $new ) {
$old = get_option( 'edd_sample_theme_license_key' );
if( $old && $old != $new ) {
delete_option( 'edd_sample_theme_license_key_status' );
}
return $new;
}
function edd_sample_theme_activate_license() {
if( isset( $_POST['edd_theme_license_activate'] ) ) {
if( ! check_admin_referer( 'edd_sample_nonce', 'edd_sample_nonce' ) )
return;
global $wp_version;
$license = trim( get_option( 'edd_sample_theme_license_key' ) );
$api_params = array(
'edd_action' => 'activate_license',
'license' => $license,
'item_name' => urlencode( EDD_SL_THEME_NAME )
);
$response = wp_remote_get( add_query_arg( $api_params, EDD_SL_STORE_URL ), array( 'timeout' => 15, 'sslverify' => false ) );
if ( is_wp_error( $response ) )
return false;
$license_data = json_decode( wp_remote_retrieve_body( $response ) );
update_option( 'edd_sample_theme_license_key_status', $license_data->license );
}
}
add_action('admin_init', 'edd_sample_theme_activate_license');
function edd_sample_theme_deactivate_license() {
if( isset( $_POST['edd_theme_license_deactivate'] ) ) {
if( ! check_admin_referer( 'edd_sample_nonce', 'edd_sample_nonce' ) )
return;
$license = trim( get_option( 'edd_sample_theme_license_key' ) );
$api_params = array(
'edd_action'=> 'deactivate_license',
'license' => $license,
'item_name' => urlencode( EDD_SL_THEME_NAME )
);
$response = wp_remote_get( add_query_arg( $api_params, EDD_SL_STORE_URL ), array( 'timeout' => 15, 'sslverify' => false ) );
if ( is_wp_error( $response ) )
return false;
$license_data = json_decode( wp_remote_retrieve_body( $response ) );
if( $license_data->license == 'deactivated' )
delete_option( 'edd_sample_theme_license_key_status' );
}
}
add_action('admin_init', 'edd_sample_theme_deactivate_license');
function edd_sample_theme_check_license() {
global $wp_version;
$license = trim( get_option( 'edd_sample_theme_license_key' ) );
$api_params = array(
'edd_action' => 'check_license',
'license' => $license,
'item_name' => urlencode( EDD_SL_THEME_NAME )
);
$response = wp_remote_get( add_query_arg( $api_params, EDD_SL_STORE_URL ), array( 'timeout' => 15, 'sslverify' => false ) );
if ( is_wp_error( $response ) )
return false;
$license_data = json_decode( wp_remote_retrieve_body( $response ) );
if( $license_data->license == 'valid' ) {
echo 'valid'; exit;
} else {
echo 'invalid'; exit;
}
}