From 60fe77cc9f15de09dd305e84cf46a26df5d03e6c Mon Sep 17 00:00:00 2001 From: savvasha Date: Wed, 28 Apr 2021 08:09:35 +0300 Subject: [PATCH 1/7] Create a function to support custom flags --- includes/sp-core-functions.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/includes/sp-core-functions.php b/includes/sp-core-functions.php index cad4706c..68039349 100644 --- a/includes/sp-core-functions.php +++ b/includes/sp-core-functions.php @@ -1715,3 +1715,22 @@ function sp_has_shortcodes( $content, $tags ) { } return false; } + +/** + * Check if a custom flag was uploaded from the user + * @return bool + */ +function sp_flags( $nationality ) { + $nationality = strtolower( $nationality ); + $flag = ''; + global $wpdb; + $flag_post_id = intval( $wpdb->get_var( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_value LIKE '%/$nationality'" ) ); + if ( $flag_post_id ) { + $flag_src = wp_get_attachment_image_url( $flag_post_id, 'thumbnail', false ); + $flag = '' . $nationality . ''; + }else{ + $flag = '' . $nationality . ''; + } + + return $flag; +} From c482a66feef6da3e9aaf27f2dd3309d3551a52de Mon Sep 17 00:00:00 2001 From: savvasha Date: Wed, 28 Apr 2021 08:10:16 +0300 Subject: [PATCH 2/7] Add function to templates --- templates/official-details.php | 2 +- templates/player-details.php | 2 +- templates/player-list.php | 2 +- templates/staff-details.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/official-details.php b/templates/official-details.php index 48be84c1..3837ce33 100644 --- a/templates/official-details.php +++ b/templates/official-details.php @@ -51,7 +51,7 @@ if ( $show_nationality ): $values = array(); foreach ( $nationalities as $nationality ): $country_name = sp_array_value( $countries, $nationality, null ); - $values[] = $country_name ? ( $show_nationality_flags ? '' . $nationality . ' ' : '' ) . $country_name : '—'; + $values[] = $country_name ? ( $show_nationality_flags ? sp_flags( $nationality ) : '' ) . $country_name : '—'; endforeach; $common[ __( 'Nationality', 'sportspress' ) ] = implode( '
', $values ); endif; diff --git a/templates/player-details.php b/templates/player-details.php index 3a2c742d..52028411 100644 --- a/templates/player-details.php +++ b/templates/player-details.php @@ -51,7 +51,7 @@ if ( $show_nationality ): $values = array(); foreach ( $nationalities as $nationality ): $country_name = sp_array_value( $countries, $nationality, null ); - $values[] = $country_name ? ( $show_nationality_flags ? '' . $nationality . ' ' : '' ) . $country_name : '—'; + $values[] = $country_name ? ( $show_nationality_flags ? sp_flags( $nationality ) . $nationality . '"> ' : '' ) . $country_name : '—'; endforeach; $common[ __( 'Nationality', 'sportspress' ) ] = implode( '
', $values ); endif; diff --git a/templates/player-list.php b/templates/player-list.php index bab8abd2..114e201c 100644 --- a/templates/player-list.php +++ b/templates/player-list.php @@ -179,7 +179,7 @@ foreach ( $groups as $group ): $nationalities = $player->nationalities(); if ( ! empty( $nationalities ) ): foreach ( $nationalities as $nationality ): - $name = '' . $nationality . '' . $name; + $name = '' . sp_flags( $nationality ) . '' . $name; endforeach; $name_class .= ' has-photo'; endif; diff --git a/templates/staff-details.php b/templates/staff-details.php index ce04eb61..9fca30a9 100644 --- a/templates/staff-details.php +++ b/templates/staff-details.php @@ -41,7 +41,7 @@ if ( $show_nationality && $nationalities && is_array( $nationalities ) ): $nationality = sp_array_value( $legacy, $nationality, null ); endif; $country_name = sp_array_value( $countries, $nationality, null ); - $values[] = $country_name ? ( $show_nationality_flags ? '' . $nationality . ' ' : '' ) . $country_name : '—'; + $values[] = $country_name ? ( $show_nationality_flags ? sp_flags( $nationality ) : '' ) . $country_name : '—'; endforeach; $data[ __( 'Nationality', 'sportspress' ) ] = implode( '
', $values ); endif; From 58a906d330a7740a79a551dcd2b06e577e875160 Mon Sep 17 00:00:00 2001 From: savvasha Date: Wed, 28 Apr 2021 09:06:35 +0300 Subject: [PATCH 3/7] Fix a type error... --- templates/player-details.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/player-details.php b/templates/player-details.php index 52028411..7dbf55de 100644 --- a/templates/player-details.php +++ b/templates/player-details.php @@ -51,7 +51,7 @@ if ( $show_nationality ): $values = array(); foreach ( $nationalities as $nationality ): $country_name = sp_array_value( $countries, $nationality, null ); - $values[] = $country_name ? ( $show_nationality_flags ? sp_flags( $nationality ) . $nationality . '"> ' : '' ) . $country_name : '—'; + $values[] = $country_name ? ( $show_nationality_flags ? sp_flags( $nationality ) : '' ) . $country_name : '—'; endforeach; $common[ __( 'Nationality', 'sportspress' ) ] = implode( '
', $values ); endif; From d714fd79b886a7ac4e8803b02b5278fc3544bb75 Mon Sep 17 00:00:00 2001 From: savvasha Date: Wed, 28 Apr 2021 10:09:02 +0300 Subject: [PATCH 4/7] New flags --- includes/class-sp-countries.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/includes/class-sp-countries.php b/includes/class-sp-countries.php index c6fee338..f617572e 100644 --- a/includes/class-sp-countries.php +++ b/includes/class-sp-countries.php @@ -68,6 +68,7 @@ class SP_Countries { 'nam', 'nga', 'nig', + 'reu', 'rsa', 'rwa', 'sdn', @@ -207,6 +208,8 @@ class SP_Countries { 'cuw', 'dma', 'dom', + 'glp', + 'grl', 'grn', 'gua', 'hai', @@ -214,12 +217,14 @@ class SP_Countries { 'jam', 'lca', 'mex', + 'mtq', 'msr', 'nca', 'pan', 'pur', 'skn', 'slv', + 'sxm', 'tca', 'usa', 'vgb', @@ -242,6 +247,7 @@ class SP_Countries { 'nzl', 'plw', 'png', + 'pyf', 'sam', 'sol', 'tah', @@ -257,6 +263,7 @@ class SP_Countries { 'chi', 'col', 'ecu', + 'guf', 'guy', 'par', 'per', @@ -338,6 +345,8 @@ class SP_Countries { 'fin' => __( "Finland", 'sportspress' ), 'fra' => __( "France", 'sportspress' ), 'fro' => __( "Faroe Islands", 'sportspress' ), + 'guf' => __( "French Guiana", 'sportspress' ), + 'pyf' => __( "French Polynesia", 'sportspress' ), 'fsm' => __( "Micronesia", 'sportspress' ), 'gab' => __( "Gabon", 'sportspress' ), 'gam' => __( "Gambia", 'sportspress' ), @@ -346,8 +355,10 @@ class SP_Countries { 'ger' => __( "Germany", 'sportspress' ), 'gha' => __( "Ghana", 'sportspress' ), 'gib' => __( "Gibraltar", 'sportspress' ), + 'glp' => __( "Guadeloupe", 'sportspress' ), 'gnb' => __( "Guinea-Bissau", 'sportspress' ), 'gre' => __( "Greece", 'sportspress' ), + 'grl' => __( "Greenland", 'sportspress' ), 'grn' => __( "Grenada", 'sportspress' ), 'gua' => __( "Guatemala", 'sportspress' ), 'gui' => __( "Guinea", 'sportspress' ), @@ -373,6 +384,7 @@ class SP_Countries { 'kos' => __( "Kosovo", 'sportspress' ), 'kgz' => __( "Kyrgyzstan", 'sportspress' ), 'kir' => __( "Kiribati", 'sportspress' ), + 'mtq' => __( "Martinique", 'sportspress' ), 'kor' => __( "South Korea", 'sportspress' ), 'ksa' => __( "Saudi Arabia", 'sportspress' ), 'kuw' => __( "Kuwait", 'sportspress' ), @@ -433,6 +445,7 @@ class SP_Countries { 'qat' => __( "Qatar", 'sportspress' ), 'rou' => __( "Romania", 'sportspress' ), 'rsa' => __( "South Africa", 'sportspress' ), + 'reu' => __( "Reunion", 'sportspress' ), 'rus' => __( "Russia", 'sportspress' ), 'rwa' => __( "Rwanda", 'sportspress' ), 'sam' => __( "Samoa", 'sportspress' ), @@ -457,6 +470,7 @@ class SP_Countries { 'svn' => __( "Slovenia", 'sportspress' ), 'swe' => __( "Sweden", 'sportspress' ), 'swz' => __( "Eswatini", 'sportspress' ), + 'sxm' => __( "Sint Maarten", 'sportspress' ), 'syr' => __( "Syria", 'sportspress' ), 'tah' => __( "Tahiti", 'sportspress' ), 'tan' => __( "Tanzania", 'sportspress' ), From db8bdd1d1813f6ece833b623b080cf11f0cf597a Mon Sep 17 00:00:00 2001 From: savvasha Date: Wed, 28 Apr 2021 10:23:32 +0300 Subject: [PATCH 5/7] Images for French Guiana, French Polynesia, Guadeloupe, Greenland and Martinique --- assets/images/flags/glp.png | Bin 0 -> 121 bytes assets/images/flags/grl.png | Bin 0 -> 1129 bytes assets/images/flags/guf.png | Bin 0 -> 121 bytes assets/images/flags/mtq.png | Bin 0 -> 2141 bytes assets/images/flags/pyf.png | Bin 0 -> 1120 bytes 5 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 assets/images/flags/glp.png create mode 100644 assets/images/flags/grl.png create mode 100644 assets/images/flags/guf.png create mode 100644 assets/images/flags/mtq.png create mode 100644 assets/images/flags/pyf.png diff --git a/assets/images/flags/glp.png b/assets/images/flags/glp.png new file mode 100644 index 0000000000000000000000000000000000000000..576c038f6191c7e3caebd290c887f84b30aa9f79 GIT binary patch literal 121 zcmeAS@N?(olHy`uVBq!ia0vp^;y}#L!2~25&K_n2Qfx`y?k)`fL2$v|<&%LTdY&$h zAr`&KDFO3NH848aObPcdJTCG-DB^SWb330xH6KNz11mHaFYB3Q6yd|jU|7zcdpqB` Q1*nt3)78&qol`;+0Fh=St^fc4 literal 0 HcmV?d00001 diff --git a/assets/images/flags/grl.png b/assets/images/flags/grl.png new file mode 100644 index 0000000000000000000000000000000000000000..1adea9eb9fcd199731d8320c23c9ca8aa1624aef GIT binary patch literal 1129 zcmaJ=e`pg|9KTxB;S^DaI#E2&6)c$h71K6HV@!G%4dhBqG7KW(_3ouP;@vy%Ud=UX zi9tj`LC0WVr&I^-51~-1ST?~wrr@tCj)@X1tPHXGkB%wbprd9GAISJsG!(@h-k1Ika0ul z0ZE`}eFyG>c7kYZ($g7~krRRn4O;PhXxFeXnjqT4uBE7XfXHspqnjb>&5t)JQrAM% zu7J$SRtL!GJBl_)6+6>vF|P(SD!i3!cLhvf0HlzvvEOtAH$=_y3i#}q8H${BLHQ8% zA*qbqMRq_NkS#RpQ(3l!Yz@*}%a+!Fe>2ImJjbv+!v%aCCj@wb^OJKQg`?S8R!EAm zxmfrXqH+jX0>cyv1-js;q20r9!C=ti;CUbR@Hu@ZQe2kx^>Y#H^37qjy17VFT`Yr>VZ7OXH0!Df3&=axl#4Gl?E@1F-p0!A zNu;v)RaD|)B<)tZr)OrujkilDkFF`rPfb4k?&bRHYyX`3-G66!|K5wa_1XTt)0f#x ze@%}6?0a+FUGFE82#l)#V$QdPZeL=gEPYm?&Y7a92}UpI6OEKzO?((M8usgH|=2? rzuI@^w+9WsCf=S}J(hlWnrK)+EW4$5m4~-1_a1*->J*2f`^x_Svde>~ literal 0 HcmV?d00001 diff --git a/assets/images/flags/guf.png b/assets/images/flags/guf.png new file mode 100644 index 0000000000000000000000000000000000000000..576c038f6191c7e3caebd290c887f84b30aa9f79 GIT binary patch literal 121 zcmeAS@N?(olHy`uVBq!ia0vp^;y}#L!2~25&K_n2Qfx`y?k)`fL2$v|<&%LTdY&$h zAr`&KDFO3NH848aObPcdJTCG-DB^SWb330xH6KNz11mHaFYB3Q6yd|jU|7zcdpqB` Q1*nt3)78&qol`;+0Fh=St^fc4 literal 0 HcmV?d00001 diff --git a/assets/images/flags/mtq.png b/assets/images/flags/mtq.png new file mode 100644 index 0000000000000000000000000000000000000000..deefcae666ce7140d663c4df529e72100e498ed3 GIT binary patch literal 2141 zcmaJ?X;f3!7S4JOjW`sk6IdVwkU_|BNkS5d2n3!%!Vm_-R0+u?iOEeua)Cfqs(=bF z7(ixl07a`65Kt=eaAHtPP-IZyDK5oU0;mO49BBJ)RP6hq@2++4IcKl^ef!&Ie{0>$ zK>vR(HZn6pp-_ui8<`wrU5UI)(esfnMdjLpET*tG7Y>%k!AU$Ni1HA~V?hiH;t4?x z$P*;TUkBY#s5!Rc5H8GR`_cJw2*)$z;M9-;L8DM^?rH^(F9BgpEGQJq7})2{7qJ+z zfPvjiW)s*7FHj`jn4$!OQ~X2tDH1+SfOTJwaZ}R~0tke87&Ro7spx73_B}5h*&D)m zEarU*EMZ_jh~lyXFdh@s#J&U^xaf^ntch!m15*~JM15C9^c0N{yaXCjeK2Ixc= z%*O|dR8tD#=p3fc$6CmVffd29f{w>0B_-jKTyS!w5KpAhXa)`da7HqmRmn1#r*@X9 ztY;aRpo*^)D`2r)hA}YmV&w@i1B)pA&;q3RL@QH$ye8zr@M@j{Ps9-nEzKsf+5bNk zf<9%dU=H}V-p>-NLXs6Ao&&1n2}(XPxHxM=DFxk23G!gMGDI$y&fa36NDj+YBDn$s z05}(nJ)6fD%M1~R_YgLl&XTEMo{SH&m<%jJf)k4cbPAQ??L(n>dJu>Jk?8H|$)tLC z69K9xKp?yNP(5a`OgTRR0%hx)=}8z2QznF%VziJ-toDTgrcyQYgjqs4>F zbOlIc0O2EiUdsop;LBP(zNiI{h`}3X`#-au4Iu_HY(F^{IehXyC_@adM4ZhZsUe_H zb8oPi9wF+%sC=kiz2S@!nx)?ipBS(V17+DcKYQ(a42(-g4EgjzlSaq3?I z8wzdn^rXzaZO5wm`*4ffNzlOC)=pu~^2H19S0;_`L+`WAsJiAv%JWIj<2}@7@6C#> zRV#O-iHci7ieFgdc2#B6y4!QIusRW`{MG z(s$?d*3i7dhnAu-3!8%LLBGLMZ-Z-te&z0pBJdKt?XU5AhEoRV!`oi77yfz4UX}=h3C`_|I%u=V2=2@kj&Z-_fGcZIlfwd(ck%szpz$oHcdY% zJjf%h2yO17cG*el0J1WE&e?`1F$7yhNtQ#8zTa25Xx>%y+g7*clck#vhG&P@4tL+` zE#G>~dXP%d&4l}xIwr-B7P(#b%fml_t~}gGJZ5p` ze#}+K(aNkqZy6NHY0T}POI3_Q>49ARP}j6@kKSD0@hj2Vp^a1+I+XS>KY(<*uTJ*{ z>wYL$^nA?fTch|!Fb8a`+6^Z5Rj-r>oF$+Fy$LEg+HEhs!Ej6)~+1W`_6P! z4_OTEp%X@RYNuzZbZ4`+>WKE+-v7y5+&A$uBk}0=E#?;6)Xi;^y=T|0a-!*WSL(e= zexF*n`_+=L;cKU~e>h)4#p32z27U#K Q4L^LAw?DJSGiKL+0ebz05dZ)H literal 0 HcmV?d00001 diff --git a/assets/images/flags/pyf.png b/assets/images/flags/pyf.png new file mode 100644 index 0000000000000000000000000000000000000000..96663c64e962ad802961129ff6f5bc3b53ab49c9 GIT binary patch literal 1120 zcmaJ=TWHi+7>=-Fq524Lz|qKoHm(? zRAgBY)YK zedl;v>#oZ3jpYPERHk-IX}oX1Yi-$b{69K*XBpnAP_h%X!*1j%HXsrj%mOlHC^?V@ zik3e#0b&HPVzZvxGI8F@lA{Qi!ABCgYTDO>%T8gpo zEl%|yWQh#px-RVoX=vvdP7nm2gXaU-BjDssq<8_-sVy-`z)@}8LOL`_pHa!eeiWy0 zrgJ42);z806x)Ow#(0Xwa5U?eRC1K%@4FhtytjkWU?JZ{iJeT|0!$h>u-{hk;JR!5 zP?p$i0|h}l17TmOi)}p+L8k{=B+t`9a+|EEy6IcC&q8EbOqmW+OckW0IE6`QUDw1! zNQ&@vbyilz$Un|27hmSJ4@@k0 z8!P+%=bDT7RXk2fiH!F=8{7KF-A3+U_QI+Qzir Date: Wed, 28 Apr 2021 17:42:00 +0300 Subject: [PATCH 6/7] Images for Sint Maarten and Reunion --- assets/images/flags/reu.png | Bin 0 -> 121 bytes assets/images/flags/sxm.png | Bin 0 -> 1459 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 assets/images/flags/reu.png create mode 100644 assets/images/flags/sxm.png diff --git a/assets/images/flags/reu.png b/assets/images/flags/reu.png new file mode 100644 index 0000000000000000000000000000000000000000..576c038f6191c7e3caebd290c887f84b30aa9f79 GIT binary patch literal 121 zcmeAS@N?(olHy`uVBq!ia0vp^;y}#L!2~25&K_n2Qfx`y?k)`fL2$v|<&%LTdY&$h zAr`&KDFO3NH848aObPcdJTCG-DB^SWb330xH6KNz11mHaFYB3Q6yd|jU|7zcdpqB` Q1*nt3)78&qol`;+0Fh=St^fc4 literal 0 HcmV?d00001 diff --git a/assets/images/flags/sxm.png b/assets/images/flags/sxm.png new file mode 100644 index 0000000000000000000000000000000000000000..f7383931784f28d8bb52c26ed006718825e03416 GIT binary patch literal 1459 zcmeAS@N?(olHy`uVBq!ia0vp^;y}#L!3HANhlBws$r9IylHmNblJdl&R0hYC{G?O` z&)mfH)S%SFl*+=BsWuD@%*vS|5hW46K32*3xq68pHF_1f1wh>l3^w)^1&PVosU-?Y zsp*+{wo31J?^jaDOtDo8H}y5}EpSfF$n>ZxN)4{^3rViZPPR-@vbR&PsjvbXkegbP zs8ErclUHn2VXFi-*9yo63F|8fk zzE+-j#U+V($*G<$wn{)F^fEJ3tjsLTT;0sf+#C%IjSLN4ot#`O99<2KES!uCOwHXa z9ASE0@{>z*Q}aq-dQ;$f%?)ts1*L`D0-((qV)`e;62;)I41rLn>~q znd0pu94OMZKT})R;&NMp_JRk^Ei+CWUT}1Wp&{?V*44*4+#dhl`*CAI>Y+m?4(&*M z+0?qrp|?LnxI;R#CLx9~G-aWNE8A_Mrnf!08|O+cU)#xTKBa0>wYd7u|CZnP-?wd& zl9=#x-MU*jL4j}PS#5|oa6!{hrT8pYTcXOA8*@~Ce_yzVGw9ixLt0jbTXI&iig@R3 zuex((zucl-zolj#v6*=@lck%t<y?#uVzWieYUVGxw157WIX&|_l%H_vD1TahX`{*Ez3!ZQtDRa`H_ED4Wz=2iFFAeu z%+25o`}%;e&2q}$FSG^D*-@G}P5S-wn`KrF#i`bf4{T@cHM%r&@|DWH8OQq{%#vWf zm?xE~>1N|olGb4M-({mbnP zEbR_Vi_lJH6gB0QKFnRSy2|fynEXP2C0X$}fz4$OU%5WZi#VRvzw6=C_r>GU4~6(e zylGBLYpdCIzn8h5f4%tYAKA%bybCY#MxFb-^ztNk!^NqpbK57(Jp3-g*Cg;{<7p}9 zTIYal_Xt&|Z5c9C>n-ZP3VxH> Date: Wed, 28 Apr 2021 17:50:03 +0300 Subject: [PATCH 7/7] Set the custom flag size to W:23px and H:15px --- includes/sp-core-functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/sp-core-functions.php b/includes/sp-core-functions.php index 68039349..2b91b7ca 100644 --- a/includes/sp-core-functions.php +++ b/includes/sp-core-functions.php @@ -1726,7 +1726,7 @@ function sp_flags( $nationality ) { global $wpdb; $flag_post_id = intval( $wpdb->get_var( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_value LIKE '%/$nationality'" ) ); if ( $flag_post_id ) { - $flag_src = wp_get_attachment_image_url( $flag_post_id, 'thumbnail', false ); + $flag_src = wp_get_attachment_image_url( $flag_post_id, array( 23,15), false ); $flag = '' . $nationality . ''; }else{ $flag = '' . $nationality . '';