How to use writeLabel method of script class

Best Atoum code snippet using script.writeLabel

cms_export.php

Source:cms_export.php Github

copy

Full Screen

1<?php2/****************************************************************3* Script : PHP ñêðèïò ôîðìèðîâàíèÿ îò÷åòîâ â Excell ôàéë4* Author : LiO 5* Version : 0.16* Copyright : GNU LGPL7* URL : http://lio.kz8* Last modified : 08.07.20049* Description : Îáúåêò ôîðìèðîâàíèÿ xls ôàéëà. Ôàéë ìîæåò áûòü10* ñîõðàíåí ôèçè÷åñêè íà äèñê äëÿ äàëüíåéøåé ðàáîòû (ïåðåäà÷à,11* îòïðàâêà íà e-mail è ò.ä.). Òàê æå ìîæíî ñðàçó "ïîêàçàòü" ñòðóêòóðó12* Äàííûé ñêðèïò ïîääåðæèâàåò ôîðìàò Excell 5, ñ îãðàíè÷åíèÿìè -13* íå áîëåå 255 ñòîëáöîâ, è 65535 ñòðîê.14*15* Îòëå÷èñòåëüíûå îñîáåííîñòè îò äðóãèõ ñêðèïòîâ16* 1. Ôîðìèðîâàíèÿ àòðèáóòîâ ÿ÷ååê (îáðàìëåíèå)17* 2. Îòäåëüíàÿ çàïèñü öåëûõ ÷èñåë è âåùåñòâåííûõ18* 3. Êîððåêòèðîâêà ñòèëåé øðèôòîâ è ðàçìåðà19******************************************************************/20class PhpToExcell {21 var $data = ""; // äàííûå ñòðóêòóðû22 23 // ôîðìèðîâàíèÿ çàãîëîâêà îòêðûòèÿ24 function ExBOF() {25 // begin of the excel file header26 $this->data = pack("c*", 0x09, 0x00, 0x04, 0x00, 0x02, 0x00, 0x10, 0x0);27 }28 29 // ôîðìèðîâàíèÿ çàãîëîâêà çàêðûòèÿ30 function ExEOF() {31 $this->data .= pack("cc", 0x0A, 0x00);32 }33 34 // Ïåðåâîäèò â ñòðîêó attr1..335 function RowAttr($attr1,$attr2,$attr3) {36 return chr($attr1).chr($attr2).chr($attr3);37 }38 39 // óñòàíàâëèâàåò ðóññêèé ÿçûê â ñòðóêòóðà xls40 function Rus() {41 $this->data .= (chr(0x42).chr(0x00).chr(0x02).chr(0x00).chr(0x01).chr(0x80));42 }43 44 // çàïèñü ñòðîêè45 // Col,Row - êîëîíêà è ñòðîêà46 // attr1 - àòðèáóò ïîêàçà ÿ÷åéêè è çàùèòà îò çàïèñè47 // attr2 - ðàçìåð øðèôòà48 // attr3 - îáðàìëåíèå ÿ÷åéêè49 // äëÿ ôîðìèðîâàíèÿ àòðèáóòîâ èñïîëüçóéòå ñîîòâåñòâóþùèå ôóíêöèè50 function WriteLabel($Col,$Row,$attr1=0,$attr2=0,$attr3=0,$value) {// { Çàïèñü String }51 $i=strlen($value);52 $this->data .= pack("v*",0x04,8+$i,$Col,$Row);53 $this->data .= $this->RowAttr($attr1,$attr2,$attr3);54 $this->data .= pack("c",$i);55 $this->data .= $value;56 }57 58 // óñòàíîâêà øèðèíû êîëîíêè Width*1/25659 // 3000 - 100% }60 function ColWidth($ColFirst,$ColLast,$Width) {61 $this->data .= (CHR(0x24).CHR(00).Chr(04).CHR(00).chr($ColFirst).chr($ColLast).pack('s',$Width));62 }63 64 // Óïðàâëÿåò âèäîì êîëîíîê è ñòðîê ïðè65 // ReferenceMode=1 Ñòèëü ññûëîê = R1C166 // ReferenceMode=0 Ñòèëü ññûëîê ñòàíäàðòíûé A1...67 function RefMode($ReferenceMode=1) {68 if ($ReferenceMode==1) {69 $this->data .= (CHR(0x0f).chr(0x00).chr(2).chr(0x00).chr(0x00).chr(0x00));70 } else {71 $this->data .= (CHR(0x0f).chr(0x00).chr(2).chr(0x00).chr(0x00).chr(0x01));72 }73 }74 75 // çàïèñü öåëîãî ÷èñëà76 function WriteInteger($Col,$Row,$attr1,$attr2,$attr3,$value=0) {77 $this->data.=pack("v*",0x02,0x09,$Col,$Row);78 $this->data.=$this->RowAttr($attr1,$attr2,$attr3);79 $this->data.=pack("v",$value);80 }81 82 // çàïèñü äðîáíîãî ÷èñëà83 function WriteNumber($Col,$Row,$attr1,$attr2,$attr3,$value=0.00) {84 $this->data.=pack("v*",0x03,0x0F,$Col,$Row);85 $this->data.=$this->RowAttr($attr1,$attr2,$attr3);86 $this->data.=pack("d",$value);87 }88 89 // çàïèñü ïóñòîé ÿ÷åéêè90 function WriteBlank($Col,$Row,$attr1,$attr2,$attr3) {91 $this->data.=pack("v*",0x01,0x07,$Col,$Row);92 $this->data.=$this->RowAttr($attr1,$attr2,$attr3);93 }94 95 // Óñòàíîâêà øðèôòà. Height*1/2096 // Äëÿ 10 ïóíêòîâ Height = 200 }97 function Font($Height,$Bold=0,$Italic=0,$Underline=0,$StrikeOut=0,$FontName) {98 $i=strlen($FontName);99 $this->data.=CHR(0x31).chr(0x00).Chr($i+5).chr(0x00);100 $this->data.=pack("v",$Height);101 $k=0;102 if ($Bold==1) $k=$k|1;103 if ($Italic==1) $k=$k|2;104 if ($Underline==1) $k=$k|4;105 if ($StrikeOut==1) $k=$k|8;106 $this->data.=pack("v",$k);107 $this->data.=chr($i);108 $this->data.=$FontName;109 }110 111 // Ôîðìèðóåì àòòðèáóò ¹1 ($Attr1)112 // $CellHidden - ñêðûòü ôîðìóëû113 // $CellLocked - çàùèùåííàÿ ÿ÷åéêà114 function Attr1($CellHidden=0,$CellLocked=0) {115 $r=0x0;116 if ($CellHidden==1)$r=$r|128;117 if ($CellLocked==1)$r=$r|64;118 return $r;119 }120 121 // Ôîðìèðóåì àòòðèáóò ¹2 ($Attr2)122 // $FontNumber 0..3123 function Attr2($FontNumber=0) {124 $r=0;125 switch ($FontNumber) {126 case 1:127 $r=64;128 break;129 case 2:130 $r=128;131 break;132 case 3:133 $r=129;134 break;135 }136 return $r;137 }138 139 // Ôîðìèðóåì àòòðèáóò ¹3 ($Attr3)140 // Alignment 0 - General141 // 1 - left142 // 2 - center143 // 3 - Right144 // 4 - Fill145 function Attr3($Shaded=0,$BottomBorder=0,$TopBorder=0,$RightBorder=0,$LeftBorder=0,$Alignment=0) {146 $r=0;147 if ($Shaded==1) $r=$r|128;148 if ($BottomBorder==1) $r=$r|64;149 if ($TopBorder==1) $r=$r|32;150 if ($RightBorder==1) $r=$r|16;151 if ($LeftBorder==1) $r= $r|8;152 if ($Alignment<8) $r=$r|$Alignment;153 return $r;154 }155 156 // ñîõðàíåíèå äàííûõ â xls ôàéë157 function SaveToFileXls($FName='file.xls') {158 $fp = fopen( $FName, "wb" );159 fwrite( $fp,$this->data);160 fclose( $fp );161 }162 163 // ïîêàçàòü ñòðóêòóðó â web164 function SendFileToHTTP($FName='file.xls') {165 header ( "Expires: Mon, 1 Apr 1974 05:00:00 GMT" );166 header ( "Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT" );167 header ( "Cache-Control: no-cache, must-revalidate" );168 header ( "Pragma: no-cache" );169 header ( "Content-type: application/x-msexcel" );170 header ( "Content-Disposition: attachment; filename=".$FName );171 print $this->data;172 }173}174 class cms_export_php extends CCMSPageCodeHandler 175 {176 public function cms_export_php()177 {178 $this->CCMSPageCodeHandler();179 }180 181 public function PreRender()182 {183 $table = GP("table");184 /*//header("Content-type: multipart/mixed");185 header('Content-Disposition: attachment; filename="'.$table.'.xml"');186 187 if ($table!='data')188 {189 $exTable = $this->GetControl($table);190 if (!is_null($exTable))191 {192 $data = $this->GetControl("data");193 $data->template = $exTable->Render();194 }195 }*/196 197 $xls = new PhpToExcell(); // ñîçäàíèå îáúåêòà198 199 $xls->ExBOF(); // ìàðêåð íà÷àëà ñòðóêòóðû200 $xls->Rus(); // óñòàíîâêà ðóññêîãî ÿçûêà201 $xls->RefMode(0);202 203 $filename = "data_table.xls";204 205 switch ($table) {206 207 case "areas" :208 $xls->ColWidth(0,0,10000);209 $xls->ColWidth(1,1,8000);210 $xls->ColWidth(2,2,10000);211 $xls->ColWidth(3,3,4000);212 $xls->ColWidth(4,4,12000);213 $xls->ColWidth(5,6,12000);214 $areas = SQLProvider::ExecuteQuery("select title,215 address,216 date_open,217 phone,218 site_address,219 max_count_man,220 (select GROUP_CONCAT(tbl__area_types.title SEPARATOR ', ') from tbl__area_types,tbl__area2type where tbl__area_types.tbl_obj_id=tbl__area2type.type_id and tbl__area2type.area_id=tbl__area_doc.tbl_obj_id) as type,221 (select GROUP_CONCAT(tbl__area_subtypes.title SEPARATOR ', ') from tbl__area_subtypes,tbl__area2subtype where tbl__area_subtypes.tbl_obj_id=tbl__area2subtype.subtype_id and tbl__area2subtype.area_id=tbl__area_doc.tbl_obj_id) as subtype,222 223 (select GROUP_CONCAT(tbl__area_halls.title SEPARATOR ', ') from tbl__area_halls where tbl__area_halls.area_id =tbl__area_doc.tbl_obj_id) as zal,224 (select GROUP_CONCAT(tbl__area_halls.max_places_banquet SEPARATOR ', ') from tbl__area_halls where tbl__area_halls.area_id =tbl__area_doc.tbl_obj_id) as banquet,225 (select GROUP_CONCAT(tbl__area_halls.max_places_official_buffet SEPARATOR ', ') from tbl__area_halls where tbl__area_halls.area_id =tbl__area_doc.tbl_obj_id) as buffet,226 (select tbl__city.title from tbl__city where tbl__city.tbl_obj_id = tbl__area_doc.city) city_name,227 email228 from tbl__area_doc where active=1 order by title");229 foreach ($areas as $key=>$area) {230 $xls->WriteLabel($key,0,0,0,0,$area["title"]);231 $xls->WriteLabel($key,1,0,0,0,$area["phone"]);232 $xls->WriteLabel($key,2,0,0,0,$area["site_address"]);233 $xls->WriteLabel($key,3,0,0,0,$area["max_count_man"]);234 $xls->WriteLabel($key,4,0,0,0,$area["type"]);235 $xls->WriteLabel($key,5,0,0,0,$area["subtype"]);236 $xls->WriteLabel($key,6,0,0,0,$area["address"]);237 $xls->WriteLabel($key,7,0,0,0,$area["zal"]);238 $xls->WriteLabel($key,8,0,0,0,$area["banquet"]);239 $xls->WriteLabel($key,9,0,0,0,$area["buffet"]);240 $xls->WriteLabel($key,10,0,0,0,$area["date_open"]);241 $xls->WriteLabel($key,11,0,0,0,$area["city_name"]);242 $xls->WriteLabel($key,12,0,0,0,$area["email"]);243 }244 $filename = "areas_table.xls";245 break;246 247 case "contractors" :248 $xls->ColWidth(0,0,10000);249 $xls->ColWidth(1,1,4000);250 $xls->ColWidth(2,2,4000);251 $xls->ColWidth(3,3,10000);252 $xls->ColWidth(4,4,8000);253 $xls->ColWidth(5,6,12000);254 $areas = SQLProvider::ExecuteQuery("select title,255 address,256 phone,257 phone2,258 site_address,259 (select GROUP_CONCAT(tbl__activity_type.title SEPARATOR ', ') from tbl__activity_type,tbl__contractor2activity where tbl__activity_type.tbl_obj_id=tbl__contractor2activity.kind_of_activity and tbl__contractor2activity.tbl_obj_id=tbl__contractor_doc.tbl_obj_id and tbl__activity_type.parent_id=0) as type,260 (select GROUP_CONCAT(tbl__activity_type.title SEPARATOR ', ') from tbl__activity_type,tbl__contractor2activity where tbl__activity_type.tbl_obj_id=tbl__contractor2activity.kind_of_activity and tbl__contractor2activity.tbl_obj_id=tbl__contractor_doc.tbl_obj_id and tbl__activity_type.parent_id<>0) as subtype,261 (select tbl__city.title from tbl__city where tbl__city.tbl_obj_id = tbl__contractor_doc.city) as city_name,262 email,263 description264 from tbl__contractor_doc where active=1 order by title");265 foreach ($areas as $key=>$area) {266 $xls->WriteLabel($key,0,0,0,0,$area["title"]);267 $xls->WriteLabel($key,1,0,0,0,$area["phone"]);268 $xls->WriteLabel($key,2,0,0,0,$area["phone2"]);269 $xls->WriteLabel($key,3,0,0,0,$area["site_address"]);270 $xls->WriteLabel($key,4,0,0,0,$area["type"]);271 $xls->WriteLabel($key,5,0,0,0,$area["subtype"]);272 $xls->WriteLabel($key,6,0,0,0,$area["address"]);273 $xls->WriteLabel($key,7,0,0,0,$area["city_name"]);274 $xls->WriteLabel($key,8,0,0,0,$area["email"]);275 $ddd = $area["description"];276 $n = strlen($ddd);277 $col = 9;278 for ($i = 0; $i < $n; $i += 200) 279 {280 $xls->WriteLabel($key,$col,0,0,0,substr($ddd,$i,200));281 $col++;282 } 283 }284 $filename = "contractors_table.xls";285 break;286 287 case "artists" :288 $xls->ColWidth(0,0,10000);289 $xls->ColWidth(1,1,5000);290 $xls->ColWidth(2,2,10000);291 $xls->ColWidth(3,3,8000);292 $xls->ColWidth(4,4,12000);293 $areas = SQLProvider::ExecuteQuery("select title,294 manager_phone,295 site_address,296 (select title from tbl__artist_group where tbl__artist_group.tbl_obj_id=tbl__artist_doc.group limit 1) as type,297 (select GROUP_CONCAT(tbl__artist_subgroup.title SEPARATOR ', ') from tbl__artist_subgroup,tbl__artist2subgroup where tbl__artist_subgroup.tbl_obj_id=tbl__artist2subgroup.subgroup_id and tbl__artist2subgroup.artist_id=tbl__artist_doc.tbl_obj_id) as subtype,298 (select tbl__countries.title from tbl__countries where tbl__countries.tbl_obj_id = tbl__artist_doc.country) country_name,299 email,300 manager_name,301 description302 from tbl__artist_doc where active=1 order by title");303 foreach ($areas as $key=>$area) {304 $xls->WriteLabel($key,0,0,0,0,$area["title"]);305 $xls->WriteLabel($key,1,0,0,0,$area["manager_phone"]);306 $xls->WriteLabel($key,2,0,0,0,$area["site_address"]);307 $xls->WriteLabel($key,3,0,0,0,$area["type"]);308 $xls->WriteLabel($key,4,0,0,0,$area["subtype"]);309 $xls->WriteLabel($key,5,0,0,0,$area["country_name"]);310 $xls->WriteLabel($key,6,0,0,0,$area["email"]);311 $xls->WriteLabel($key,7,0,0,0,$area["manager_name"]);312 $ddd = $area["description"];313 $n = strlen($ddd);314 $col = 8;315 for ($i = 0; $i < $n; $i += 200) 316 {317 $xls->WriteLabel($key,$col,0,0,0,substr($ddd,$i,200));318 $col++;319 }320 }321 $filename = "artists_table.xls";322 break;323 324 case "agencies" :325 $xls->ColWidth(0,0,10000);326 $xls->ColWidth(1,1,5000);327 $xls->ColWidth(2,2,5000);328 $xls->ColWidth(3,3,10000);329 $xls->ColWidth(4,4,8000);330 $areas = SQLProvider::ExecuteQuery("select title,331 address,332 phone,333 phone2,334 site_address,335 (select title from tbl__agency_type where tbl__agency_type.tbl_obj_id=tbl__agency_doc.kind_of_activity limit 1) as type,336 (select tbl__city.title from tbl__city where tbl__city.tbl_obj_id = tbl__agency_doc.city) as city_name,337 email,338 description339 from tbl__agency_doc where active=1 order by title");340 foreach ($areas as $key=>$area) {341 $xls->WriteLabel($key,0,0,0,0,$area["title"]);342 $xls->WriteLabel($key,1,0,0,0,$area["phone"]);343 $xls->WriteLabel($key,2,0,0,0,$area["phone2"]);344 $xls->WriteLabel($key,3,0,0,0,$area["site_address"]);345 $xls->WriteLabel($key,4,0,0,0,$area["type"]);346 $xls->WriteLabel($key,5,0,0,0,$area["address"]);347 $xls->WriteLabel($key,6,0,0,0,$area["city_name"]);348 $xls->WriteLabel($key,7,0,0,0,$area["email"]);349 $ddd = $area["description"];350 $n = strlen($ddd);351 $col = 8;352 for ($i = 0; $i < $n; $i += 200) 353 {354 $xls->WriteLabel($key,$col,0,0,0,substr($ddd,$i,200));355 $col++;356 } 357 }358 $filename = "agencies_table.xls";359 break;360 case "users" :361 $xls->ColWidth(0,0,4000);362 $xls->ColWidth(1,1,10000);363 $xls->ColWidth(1,2,10000);364 $xls->ColWidth(2,3,5000);365 $xls->ColWidth(3,4,5000);366 $xls->ColWidth(4,5,5000);367 $xls->ColWidth(5,6,10000);368 $xls->ColWidth(6,7,10000);369 $xls->ColWidth(7,8,8000);370 $xls->ColWidth(8,9,5000);371 $xls->ColWidth(9,10,10000);372 $xls->ColWidth(10,11,8000);373 $xls->ColWidth(11,12,8000);374 $xls->ColWidth(12,13,8000);375 $xls->ColWidth(13,14,5000); 376 $users = SQLProvider::ExecuteQuery(" select 377 ru.tbl_obj_id,378 rut.user_types,379 ru.title,380 if(ru.city>0,c.title,ru.sity) as city,381 contact_phone,382 email,383 company,384 field_of_activity,385 `position`,386 company_phone,387 address,388 login,389 nikname,390 forum_name,391 registration_date,392 registration_confirmed393 from tbl__registered_user ru394 left join tbl__city c on ru.city=c.tbl_obj_id395 left join 396 (select user_id, GROUP_CONCAT(user_type SEPARATOR ', ') user_types397 from tbl__registered_user_types group by user_id) rut on rut.user_id = ru.tbl_obj_id398 where ru.active=1 order by tbl_obj_id desc"); 399 $xls->WriteLabel(0,0,0,0,$xls->Attr3(0,0,0,0,0,2),"ID");400 $xls->WriteLabel(0,1,0,0,$xls->Attr3(0,0,0,0,0,2),"Èìÿ");401 $xls->WriteLabel(0,2,0,0,$xls->Attr3(0,0,0,0,0,2),"Òèï ïîëüçîâàòåëÿ"); 402 $xls->WriteLabel(0,3,0,0,$xls->Attr3(0,0,0,0,0,2),"Ãîðîä");403 $xls->WriteLabel(0,4,0,0,$xls->Attr3(0,0,0,0,0,2),"Òåëåôîí");404 $xls->WriteLabel(0,5,0,0,$xls->Attr3(0,0,0,0,0,2),"E-mail");405 $xls->WriteLabel(0,6,0,0,$xls->Attr3(0,0,0,0,0,2),"Êîìïàíèÿ");406 $xls->WriteLabel(0,7,0,0,$xls->Attr3(0,0,0,0,0,2),"field_of_activity");407 $xls->WriteLabel(0,8,0,0,$xls->Attr3(0,0,0,0,0,2),"Äîëæíîñòü");408 $xls->WriteLabel(0,9,0,0,$xls->Attr3(0,0,0,0,0,2),"Òåëåôîí êîìïàíèè");409 $xls->WriteLabel(0,10,0,0,$xls->Attr3(0,0,0,0,0,2),"Àäðåñ");410 $xls->WriteLabel(0,11,0,0,$xls->Attr3(0,0,0,0,0,2),"Ëîãèí");411 $xls->WriteLabel(0,12,0,0,$xls->Attr3(0,0,0,0,0,2),"Íèêíýéì");412 $xls->WriteLabel(0,13,0,0,$xls->Attr3(0,0,0,0,0,2),"Èìÿ íà ôîðóìå");413 $xls->WriteLabel(0,14,0,0,$xls->Attr3(0,0,0,0,0,2),"Äàòà ðåãèñòðàöèè");414 $xls->WriteLabel(0,15,0,0,$xls->Attr3(0,0,0,0,0,2),"Ðåã. ïîäòâåðæäåíà");415 foreach ($users as $key=>$user) {416 $xls->WriteInteger($key+1,0,0,0,0,$user["tbl_obj_id"]);417 $xls->WriteLabel($key+1,1,0,0,0,$user["title"]);418 $xls->WriteLabel($key+1,2,0,0,0,$user["user_types"]);419 $xls->WriteLabel($key+1,3,0,0,0,$user["city"]);420 $xls->WriteLabel($key+1,4,0,0,0,$user["contact_phone"]);421 $xls->WriteLabel($key+1,5,0,0,0,$user["email"]);422 $xls->WriteLabel($key+1,6,0,0,0,$user["company"]);423 $xls->WriteLabel($key+1,7,0,0,0,$user["field_of_activity"]);424 $xls->WriteLabel($key+1,8,0,0,0,$user["position"]);425 $xls->WriteLabel($key+1,9,0,0,0,$user["company_phone"]);426 $xls->WriteLabel($key+1,10,0,0,0,$user["address"]);427 $xls->WriteLabel($key+1,11,0,0,0,$user["login"]);428 $xls->WriteLabel($key+1,12,0,0,0,$user["nikname"]);429 $xls->WriteLabel($key+1,13,0,0,0,$user["forum_name"]);430 $xls->WriteLabel($key+1,14,0,0,0,date("d.m.Y H:i:s",strtotime($user["registration_date"])));431 $xls->WriteLabel($key+1,15,0,0,0,$user["registration_confirmed"]=="1"?"äà":"íåò");432 }433 $filename = "users_table.xls";434 break; 435 }436 437 /*$xls->ColWidth(3,3,15000); // óñòàíîâêà øèðèíû êîëîíêè438 $xls->ColWidth(2,2,25600);439 440 $xls->WriteLabel(0,3,0,0,0,'Òåñòîâàÿ ñòðîêà'); // çàïèñü ñòðîêè441 $xls->WriteInteger(1,3,0,0,0,1223); // çàïèñü öåëîãî ÷èñëà442 $xls->WriteNumber(0,0,0,0,0,0.20); // çàïèñü äðîáíîãî ÷èñëà443 $xls->WriteBlank(1,5,0,0,0); // çàïèñü ïóñòîé ÿ÷åéêè*/444 445 $xls->ExEOF(); // ìàðêåð êîíöà ñòðóêòóðû446 447 //$xls->SaveToFileXls('data_table.xls'); // ñîõðàíèòü ôàéë448 $xls->SendFileToHTTP($filename); // âûâåñòè êëèåíòó 449 }450 }451?>...

Full Screen

Full Screen

functions.php

Source:functions.php Github

copy

Full Screen

1<?php2/**3 * Write Label functions and definitions4 *5 * @link https://developer.wordpress.org/themes/basics/theme-functions/6 *7 * @package Write_Label8 */9if ( ! defined( '_S_VERSION' ) ) {10 // Replace the version number of the theme on each release.11 define( '_S_VERSION', '1.0.0' );12}13if ( ! function_exists( 'writelabel_setup' ) ) :14 /**15 * Sets up theme defaults and registers support for various WordPress features.16 *17 * Note that this function is hooked into the after_setup_theme hook, which18 * runs before the init hook. The init hook is too late for some features, such19 * as indicating support for post thumbnails.20 */21 function writelabel_setup() {22 /*23 * Make theme available for translation.24 * Translations can be filed in the /languages/ directory.25 * If you're building a theme based on Write Label, use a find and replace26 * to change 'writelabel' to the name of your theme in all the template files.27 */28 load_theme_textdomain( 'writelabel', get_template_directory() . '/languages' );29 // Add default posts and comments RSS feed links to head.30 add_theme_support( 'automatic-feed-links' );31 /*32 * Let WordPress manage the document title.33 * By adding theme support, we declare that this theme does not use a34 * hard-coded <title> tag in the document head, and expect WordPress to35 * provide it for us.36 */37 add_theme_support( 'title-tag' );38 /*39 * Enable support for Post Thumbnails on posts and pages.40 *41 * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/42 */43 add_theme_support( 'post-thumbnails' );44 // This theme uses wp_nav_menu() in one location.45 register_nav_menus(46 array(47 'menu-1' => esc_html__( 'Primary', 'writelabel' ),48 )49 );50 /*51 * Switch default core markup for search form, comment form, and comments52 * to output valid HTML5.53 */54 add_theme_support(55 'html5',56 array(57 'search-form',58 'comment-form',59 'comment-list',60 'gallery',61 'caption',62 'style',63 'script',64 )65 );66 // Set up the WordPress core custom background feature.67 add_theme_support(68 'custom-background',69 apply_filters(70 'writelabel_custom_background_args',71 array(72 'default-color' => 'ffffff',73 'default-image' => '',74 )75 )76 );77 // Add theme support for selective refresh for widgets.78 add_theme_support( 'customize-selective-refresh-widgets' );79 /**80 * Add support for core custom logo.81 *82 * @link https://codex.wordpress.org/Theme_Logo83 */84 add_theme_support(85 'custom-logo',86 array(87 'height' => 250,88 'width' => 250,89 'flex-width' => true,90 'flex-height' => true,91 )92 );93 if( function_exists('acf_add_options_page') ) {94 acf_add_options_page(array(95 'page_title' => 'Theme General Settings',96 'menu_title' => 'Theme Settings',97 'menu_slug' => 'theme-general-settings',98 'capability' => 'edit_posts',99 'redirect' => false100 ));101 }102 }103endif;104add_action( 'after_setup_theme', 'writelabel_setup' );105/**106 * Set the content width in pixels, based on the theme's design and stylesheet.107 *108 * Priority 0 to make it available to lower priority callbacks.109 *110 * @global int $content_width111 */112function writelabel_content_width() {113 $GLOBALS['content_width'] = apply_filters( 'writelabel_content_width', 640 );114}115add_action( 'after_setup_theme', 'writelabel_content_width', 0 );116/**117 * Register widget area.118 *119 * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar120 */121function writelabel_widgets_init() {122 register_sidebar(123 array(124 'name' => esc_html__( 'Sidebar', 'writelabel' ),125 'id' => 'sidebar-1',126 'description' => esc_html__( 'Add widgets here.', 'writelabel' ),127 'before_widget' => '<section id="%1$s" class="widget %2$s">',128 'after_widget' => '</section>',129 'before_title' => '<h2 class="widget-title">',130 'after_title' => '</h2>',131 )132 );133}134add_action( 'widgets_init', 'writelabel_widgets_init' );135/**136 * Enqueue scripts and styles.137 */138function writelabel_scripts() {139 wp_enqueue_style( 'bootstrap-grid', get_template_directory_uri() . '/css/bootstrap-grid.min.css', array(), '1.0.0');140 wp_enqueue_style( 'writelabel-style', get_stylesheet_uri(), array(), _S_VERSION );141 wp_style_add_data( 'writelabel-style', 'rtl', 'replace' );142 wp_enqueue_script( 'writelabel-navigation', get_template_directory_uri() . '/js/navigation.js', array(), _S_VERSION, true );143 wp_enqueue_script( 'gsapjs', get_template_directory_uri() . '/js/gsap.min.js', array(), '1.0.0', true );144 wp_enqueue_script( 'scrolltriggerjs', get_template_directory_uri() . '/js/scrolltrigger.min.js', array(), '1.0.0', true );145 146 wp_enqueue_style( 'glidecss', get_template_directory_uri() . '/css/glide.core.min.css', array(), '1.0.0' );147 wp_enqueue_script( 'glidejs', 'https://cdn.jsdelivr.net/npm/@glidejs/glide', array(), '1.0.0', true );148 149 150 151 wp_enqueue_script( 'writelabel-js', get_template_directory_uri() . '/js/writelabel.js', array('jquery'), '1.0.0', true );152 if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {153 wp_enqueue_script( 'comment-reply' );154 }155}156add_action( 'wp_enqueue_scripts', 'writelabel_scripts' );157/**158 * Implement the Custom Header feature.159 */160require get_template_directory() . '/inc/custom-header.php';161/**162 * Custom template tags for this theme.163 */164require get_template_directory() . '/inc/template-tags.php';165/**166 * Functions which enhance the theme by hooking into WordPress.167 */168require get_template_directory() . '/inc/template-functions.php';169/**170 * Customizer additions.171 */172require get_template_directory() . '/inc/customizer.php';173/**174 * Load Jetpack compatibility file.175 */176if ( defined( 'JETPACK__VERSION' ) ) {177 require get_template_directory() . '/inc/jetpack.php';178}179function writelabel_color($color) {180 switch ($color) {181 case '#FBE8A6':182 return '#F4976C';183 break;184 case '#F4976C' :185 return '#B4DFE5';186 break; 187 default:188 return '#FBE8A6';189 break;190 }191}...

Full Screen

Full Screen

customizer.php

Source:customizer.php Github

copy

Full Screen

1<?php2/**3 * Write Label Theme Customizer4 *5 * @package Write_Label6 */7/**8 * Add postMessage support for site title and description for the Theme Customizer.9 *10 * @param WP_Customize_Manager $wp_customize Theme Customizer object.11 */12function writelabel_customize_register( $wp_customize ) {13 $wp_customize->get_setting( 'blogname' )->transport = 'postMessage';14 $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';15 $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';16 if ( isset( $wp_customize->selective_refresh ) ) {17 $wp_customize->selective_refresh->add_partial(18 'blogname',19 array(20 'selector' => '.site-title a',21 'render_callback' => 'writelabel_customize_partial_blogname',22 )23 );24 $wp_customize->selective_refresh->add_partial(25 'blogdescription',26 array(27 'selector' => '.site-description',28 'render_callback' => 'writelabel_customize_partial_blogdescription',29 )30 );31 }32}33add_action( 'customize_register', 'writelabel_customize_register' );34/**35 * Render the site title for the selective refresh partial.36 *37 * @return void38 */39function writelabel_customize_partial_blogname() {40 bloginfo( 'name' );41}42/**43 * Render the site tagline for the selective refresh partial.44 *45 * @return void46 */47function writelabel_customize_partial_blogdescription() {48 bloginfo( 'description' );49}50/**51 * Binds JS handlers to make Theme Customizer preview reload changes asynchronously.52 */53function writelabel_customize_preview_js() {54 wp_enqueue_script( 'writelabel-customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), _S_VERSION, true );55}56add_action( 'customize_preview_init', 'writelabel_customize_preview_js' );...

Full Screen

Full Screen

writeLabel

Using AI Code Generation

copy

Full Screen

1require_once('script.php');2$script = new script();3$script->writeLabel('Hello World');4require_once('script.php');5$script = new script();6$script->writeLabel('Hello World');7require_once('script.php');8$script = new script();9$script->writeLabel('Hello World');10require_once('script.php');11$script = new script();12$script->writeLabel('Hello World');13require_once('script.php');14$script = new script();15$script->writeLabel('Hello World');16require_once('script.php');17$script = new script();18$script->writeLabel('Hello World');

Full Screen

Full Screen

writeLabel

Using AI Code Generation

copy

Full Screen

1$script = new script();2$script->writeLabel("label1","This is a label");3$script = new script();4$script->writeLabel("label2","This is another label");5$script = new script();6$script->writeLabel("label3","This is yet another label");7$script = new script();8$script->writeLabel("label4","This is yet another label");9$script = new script();10$script->writeLabel("label5","This is yet another label");11$script = new script();12$script->writeLabel("label6","This is yet another label");13$script = new script();14$script->writeLabel("label7","This is yet another label");15$script = new script();16$script->writeLabel("label8","This is yet another label");17$script = new script();18$script->writeLabel("label9","This is yet another label");19$script = new script();20$script->writeLabel("label10","This is yet another label");21$script = new script();22$script->writeLabel("label11","This is yet another label");23$script = new script();24$script->writeLabel("label12","This is yet another label");25$script = new script();26$script->writeLabel("label13","This is yet another label");

Full Screen

Full Screen

writeLabel

Using AI Code Generation

copy

Full Screen

1include("script.php");2$script = new script();3$script->writeLabel("Hello World");4{5function writeLabel($label)6{7echo $label;8}9}10include("script.php");11$script = new script();12$script->writeLabel("Hello World");13{14function writeLabel($label)15{16echo $label;17}18}19include("script.php");20$script = new script();21$script->writeLabel("Hello World");22{23function writeLabel($label)24{25echo $label;26}27}28include("script.php");29$script = new script();30$script->writeLabel("Hello World");31{32function writeLabel($label)33{34echo $label;35}36}37include("script.php");38$script = new script();39$script->writeLabel("Hello World");40{41function writeLabel($label)42{43echo $label;44}45}46include("script.php");47$script = new script();48$script->writeLabel("Hello World");49{50function writeLabel($label)51{52echo $label;53}54}55include("script.php");56$script = new script();57$script->writeLabel("Hello World");58{59function writeLabel($label)60{61echo $label;62}63}

Full Screen

Full Screen

writeLabel

Using AI Code Generation

copy

Full Screen

1$script->writeLabel("label1", "Hello World");2$script->writeLabel("label1", "Hello World");3$script->writeLabel("label2", "Hello World");4$script->writeLabel("label1", "Hello World");5$script->writeLabel("label2", "Hello World");6$script->writeLabel("label3", "Hello World");7$script->writeLabel("label1", "Hello World");8$script->writeLabel("label2", "Hello World");9$script->writeLabel("label3", "Hello World");10$script->writeLabel("label4", "Hello World");11$script->writeLabel("label1", "Hello World");12$script->writeLabel("label2", "Hello World");13$script->writeLabel("label3", "Hello World");14$script->writeLabel("label4", "Hello World");15$script->writeLabel("label5", "Hello World");16$script->writeLabel("label1", "Hello World");17$script->writeLabel("label2", "Hello World");18$script->writeLabel("label3", "Hello World");

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Trigger writeLabel code on LambdaTest Cloud Grid

Execute automation tests with writeLabel on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful