diff --git a/assets/images/facebook-icon.png b/assets/images/facebook-icon.png old mode 100644 new mode 100755 index 90e254e..9f59d37 Binary files a/assets/images/facebook-icon.png and b/assets/images/facebook-icon.png differ diff --git a/assets/images/instagram-icon.png b/assets/images/instagram-icon.png new file mode 100644 index 0000000..b58e2d0 Binary files /dev/null and b/assets/images/instagram-icon.png differ diff --git a/assets/images/youtube-icon.png b/assets/images/youtube-icon.png new file mode 100644 index 0000000..90e254e Binary files /dev/null and b/assets/images/youtube-icon.png differ diff --git a/assets/js/home.js b/assets/js/home.js index 107c382..a13d347 100644 --- a/assets/js/home.js +++ b/assets/js/home.js @@ -73,4 +73,12 @@ jQuery(document).ready(function($) { $( '#youtube-content' ).html( response ); }); + var data_insta = { + action: 'csem_get_last_socials', + network: 'instagram' + } + $.get( ajax.url, data_insta, function( response ) { + $( '#instagram-content' ).html( response ); + }); + }); diff --git a/functions.php b/functions.php index d876691..7ace067 100644 --- a/functions.php +++ b/functions.php @@ -272,13 +272,13 @@ function csem_coletivo_customize_after_register( $wp_customize ) { ) ); // Textarea redes - $wp_customize->add_setting( coletivo_add_settings('coletivo_ultimos_sociais_yt'), + $wp_customize->add_setting( coletivo_add_settings('coletivo_ultimos_sociais_yt_url'), array( 'sanitize_callback' => 'sanitize_text_field', 'default' => '', ) ); - $wp_customize->add_control( coletivo_add_settings('coletivo_ultimos_sociais_yt'), + $wp_customize->add_control( coletivo_add_settings('coletivo_ultimos_sociais_yt_url'), array( 'label' => esc_html__('URL do YouTube', 'coletivo'), 'section' => 'coletivo_ultimos_sociais_content', @@ -286,19 +286,48 @@ function csem_coletivo_customize_after_register( $wp_customize ) { ) ); - $wp_customize->add_setting( coletivo_add_settings('coletivo_ultimos_sociais_instagram'), + $wp_customize->add_setting( coletivo_add_settings('coletivo_ultimos_sociais_yt_id'), array( 'sanitize_callback' => 'sanitize_text_field', 'default' => '', ) ); - $wp_customize->add_control( coletivo_add_settings('coletivo_ultimos_sociais_instagram'), + $wp_customize->add_control( coletivo_add_settings('coletivo_ultimos_sociais_yt_id'), + array( + 'label' => esc_html__('ID do Canal no Youtube', 'coletivo'), + 'section' => 'coletivo_ultimos_sociais_content', + 'description' => 'Verique o ID pelo site: https://commentpicker.com/youtube-channel-id.php', + ) + ); + + + $wp_customize->add_setting( coletivo_add_settings('coletivo_ultimos_sociais_instagram_url'), + array( + 'sanitize_callback' => 'sanitize_text_field', + 'default' => '', + ) + ); + $wp_customize->add_control( coletivo_add_settings('coletivo_ultimos_sociais_instagram_url'), array( 'label' => esc_html__('URL do Instagram', 'coletivo'), 'section' => 'coletivo_ultimos_sociais_content', 'description' => '', ) ); + $wp_customize->add_setting( coletivo_add_settings('coletivo_ultimos_sociais_instagram_token'), + array( + 'sanitize_callback' => 'sanitize_text_field', + 'default' => '', + ) + ); + $wp_customize->add_control( coletivo_add_settings('coletivo_ultimos_sociais_instagram_token'), + array( + 'label' => esc_html__('Token de acesso Instagram', 'coletivo'), + 'section' => 'coletivo_ultimos_sociais_content', + 'description' => 'Gere o token pelo site: https://instagram.pixelunion.net/', + ) + ); + $wp_customize->add_setting( coletivo_add_settings('coletivo_ultimos_sociais_fb'), array( 'sanitize_callback' => 'sanitize_text_field', diff --git a/inc/class-load-last-post-social-networks.php b/inc/class-load-last-post-social-networks.php index b51ddba..97116e9 100644 --- a/inc/class-load-last-post-social-networks.php +++ b/inc/class-load-last-post-social-networks.php @@ -60,14 +60,39 @@ public function do_ajax() { get_template_part( 'section-parts/each-social' ); wp_die(); } + if ( 'instagram' === $_REQUEST[ 'network' ] ) { + $this->get_instagram_feed(); + get_template_part( 'section-parts/each-social' ); + wp_die(); + } } + private function get_instagram_feed() { + if ( false !== get_transient( 'csem_instagram_transient' ) ) { + $this->transient = get_transient( 'csem_instagram_transient' ); + $this->image = $this->transient[ 'image' ]; + return; + } + $token = coletivo_get_theme_mod( 'coletivo_ultimos_sociais_instagram_token' ); + if ( ! $token ) { + wp_die( 'Falta o token do instagram' ); + return; + } + $instagram_api_url = 'https://api.instagram.com/v1/users/self/media/recent?access_token=' . $token; + $response = file_get_contents( $instagram_api_url ); + $json = json_decode( $response ); + //var_dump( $response ); + $this->image = $json->data[0]->images->standard_resolution->url; + $this->transient = array( 'image' => $this->image ); + set_transient( 'csem_instagram_transient', $this->transient, $this->transient_time ); + } + private function get_youtube_feed() { if ( false !== get_transient( 'csem_yt_transient' ) ) { $this->transient = get_transient( 'csem_yt_transient' ); $this->image = $this->transient[ 'image' ]; return; } - $channel_id = 'UClnwaE2l2FG0eKWR9Rc610A'; + $channel_id = coletivo_get_theme_mod( 'coletivo_ultimos_sociais_yt_id', 'UClnwaE2l2FG0eKWR9Rc610A' ); $youtube_feed_url = 'https://www.youtube.com/feeds/videos.xml?channel_id=' . $channel_id; $response = file_get_contents( $youtube_feed_url ); //var_dump( $response ); @@ -116,8 +141,8 @@ private function get_facebook_feed() { //var_dump( $response->data[0]->images[6] ); //var_dump("https://graph.facebook.com/{$feed}/photos/uploaded/?{$authentication}&limit={$maximum}&fields=images,link"); //wp_die(); - $this->image = $response->data[0]->images[6]->source; - $this->transient = array( 'image' => $this->image ); + $this->image = $response->data[0]->images[6]->source +; $this->transient = array( 'image' => $this->image ); set_transient( 'csem_fb_transient', $this->transient, $this->transient_time ); } /** diff --git a/section-parts/each-social.php b/section-parts/each-social.php index e64768e..86dadc0 100644 --- a/section-parts/each-social.php +++ b/section-parts/each-social.php @@ -1,4 +1,4 @@ -
\ No newline at end of file + diff --git a/section-parts/section-ultimos_sociais.php b/section-parts/section-ultimos_sociais.php index 48cb209..de52572 100644 --- a/section-parts/section-ultimos_sociais.php +++ b/section-parts/section-ultimos_sociais.php @@ -12,6 +12,8 @@ + diff --git a/style.css b/style.css index 225aafb..d1bd30a 100644 --- a/style.css +++ b/style.css @@ -146,6 +146,7 @@ body.home .hero-content-style1 h2.hero-large-text { */ .section-fazer-parte { padding-top:0 !important; + padding-bottom: 0 !important; } .section-fazer-parte .container { width:100%; @@ -309,3 +310,42 @@ a#featuredpage { clear: both; } } + +.section-ultimos-sociais { + background-color:#444444; + background-image: url( 'assets/images/social-bg.png' ); + background-repeat: no-repeat; + background-position: top center; + background-attachment: fixed; +} +.section-ultimos-sociais img { + width:256px; + height: 256px; + border-radius:50%; + border:10px solid #3c3c3c; +} +.section-ultimos-sociais a.slug-link { + width: 100%; + display: inline-block; + text-align: center; + color:white !important; + padding-top:15px; +} +.section-ultimos-sociais .each-social { + text-align: center; +} +.section-ultimos-sociais .each-social span.icon { + background-size: cover; + width:48px; + height:48px; + position: absolute; +} +.section-ultimos-sociais #youtube-content .each-social span.icon { + background-image: url( 'assets/images/youtube-icon.png' ); +} +.section-ultimos-sociais #facebook-content .each-social span.icon { + background-image: url( 'assets/images/facebook-icon.png' ); +} +.section-ultimos-sociais #instagram-content .each-social span.icon { + background-image: url( 'assets/images/instagram-icon.png' ); +}