From c938e1f4483310d3c5b01cfbdc4eba87585d5c73 Mon Sep 17 00:00:00 2001 From: matheusgimenez Date: Tue, 26 Feb 2019 19:25:33 -0300 Subject: [PATCH] issue #6 --- assets/images/facebook-icon.png | Bin 789 -> 445 bytes assets/images/instagram-icon.png | Bin 0 -> 997 bytes assets/images/youtube-icon.png | Bin 0 -> 789 bytes assets/js/home.js | 8 ++++ functions.php | 37 +++++++++++++++-- inc/class-load-last-post-social-networks.php | 31 ++++++++++++-- section-parts/each-social.php | 22 +++++++--- section-parts/section-ultimos_sociais.php | 2 + style.css | 40 +++++++++++++++++++ 9 files changed, 128 insertions(+), 12 deletions(-) mode change 100644 => 100755 assets/images/facebook-icon.png create mode 100644 assets/images/instagram-icon.png create mode 100644 assets/images/youtube-icon.png diff --git a/assets/images/facebook-icon.png b/assets/images/facebook-icon.png old mode 100644 new mode 100755 index 90e254e5e96de75a2bacddc78a75603684a6f1b0..9f59d37ff5daad903367615d823c6def361d35ff GIT binary patch delta 354 zcmbQrwwHNANBYZMnguU`Uel$6;2B6SR3`6ag)dD zgT@cO%1fFvTa}(`xH#|FY%d0rhSjU~u_fC~)w{r#vzslh!S~^hP3IUEZvD*{!}Qr% zyYcaXGXIU%^4tqVZ{$6Wa%ebQ!F@;kn?BR}*SR~tneS^Tj7@7w_0bhSka!9bP0l+XkK1u%~C delta 701 zcmV;u0z&=01C<7lWPbviNkl8@@WWV(skBR=w+YP)G54m; zfCc!7jue6Xz<(=j&fyXHzsAssiJ4}=;gsg#KDJ;hp63jpBY2qc64+Cxf+SSuZ8#Dd zn7p(%4SKRh;%;X_deB7aHP=Xc=@z7=&M^b>bNCs{}U ze=7OeENKNB~MI^Tumfo;Be{({@}B8>n1TtWmTYH?Xg0jZi20@Fs8b zvz-AQxQKHqW4BqWveW5%1{f0;R)QgnTXxnRVQ{!J|3a$ts0*C-2fCwN0 jhyWsh2p|F|sD2Lsg7#@wi&J>y00000NkvXXu0mjfQh-7> diff --git a/assets/images/instagram-icon.png b/assets/images/instagram-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..b58e2d0489c3cec1ae422a01d1e2b81a4f26b2d7 GIT binary patch literal 997 zcmV(_`g8%^e{{R4h=>PzAFaQARU;qF*m;eA5Z<1fd zMgRZ=lU*&~NisF?-@gn7cQl>Fd8pHMVvZhw2d%1VtbI!eIX0O`a)j4~A*IM7Zf3AH> zl9{UPEAo zq%qeG&qyjYF_c0}$!t%^n55;6;)EFPcSeU=6uc+lf%B)oQH+owu-oYuY-Y|&b^-f< z=@T6oxLCut%!a^-W4zqtKiFZVp1LQT-Rtgo**zc0qX#Uo-*3QpgKbyZWc3UfwOPAj z`ZIgCvW}j&%jx6hi}x+l9xx%J4YXM<>6WBQ9cz0<((Nh}+EG{MTH@WPdzbkn*eC%9 zC4H|E?68$;^4;2ctgVu|t89GQmVm>O{v>v8gOYYin(gY%wr7Kho#h`%N9wTCmIQPs zf`2M$O&$1atga`ayJ!S-C02_&4XzkvYvX74t|Ad|$<=!7`aDM0zZEfO|~@kF~vLdKuVT zgpANur{75d&tq&U0s(8C{x}7^$2G9qmVia}TLC_&fcM!YIu;ixDOv(%q<}LcOFy#! z9(LGWDd2UvnSHnj1iW?n#uV^8#+xD#@Wko8Dd6?iz)okJX0Q=j417#+BlO(D_#z+XKXj>G>-hz!(7 zi0rU;lO`dOMM|uY1f-P|r6~D;|E0xy?QUWAzPZ^|IEAaVO*MSWjDQDDKi+7U%izR$tcGv7U61#* z@Or$j71!fPI-QugA4=LLX-*D-&oNsM6F&6CPh@iZM5Y4l2hIY&TNwCn;9O|%q03-W zRsn~AJ*LmfIOs9p9dI8QFg@3Nz@(D+rD!A|5)cW91VjQN0g-@6KqO#_%HIJ1)*nYD TpeG0000000NkvXXu0mjf*=@*U literal 0 HcmV?d00001 diff --git a/assets/images/youtube-icon.png b/assets/images/youtube-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..90e254e5e96de75a2bacddc78a75603684a6f1b0 GIT binary patch literal 789 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=oCO|{#S9GG!XV7ZFl&wkP*5S+ zBgmJ5p-Pp3p`n?9;pcxK{gQ#9)PRBERRRNp)eHs(@%%~gN8K10m}YyrIEGZ*dUM-0 zTO?5A*vI=`6IO685fJrVsl-;}?$ROlNczXR)*p;4rX33eb6m8y3aqWs{3IB%=E^M* zO_LR^Y{@I#Ts)d)v$#rh?_Ctpa`()+l<7P9b1XMM|M`Ar`Z?S3ZBtY_m9qPqw3#{> zlo~h`kg23qsz~_AW z^TuX@y^UG_L+3ztCC?kr%OCRW6D?KxB3$mI9_hhQul4h$PTrkM4~|6_2u+`Yfhd*td(mtR)1 zNiW*@;-IR|nS;reXN7)*EbsdFe7E0Yzg;5IE@xQY9=FMu(XM(@J zVqq`jcadd_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' ); +}