'post', 'dexcp' => false, 'orient' => 'v', 'imgo' => false, 'ttgo' => false, 'dtgo' => false, 'dtfrm' => 1, 'categ' => '', 'postnr' => 20, 'linn' => 3, 'divwid' => 300, 'tbwid' => 40, 'tbhig' => 40, 'cp' => 4, 'cs' => 4, 'lwt' => 1, 'tte' => '', 'sptb' => false, 'tgtb' => false, 'ordm' => 'DESC', 'ordf' => 'ID', 'metk' => '', 'mett' => 'n', 'pgin' => '', 'pgnm' => 1, 'pgmx' => '', 'gptb' => false, 'ech' => false ), $atts)); ob_start(); $gplwtres=getPostListThumbs($ptype,$dexcp,$orient,$imgo,$ttgo,$dtgo,$dtfrm,$categ,$postnr,$linn,$divwid,$tbwid,$tbhig,$cp,$cs,$lwt,$tte,$sptb,$tgtb,$ordm,$ordf,$metk,$mett,$pgin,$gptb,$pgnm,$pgmx,$ech); echo $gplwtres; $gplwt_string = ob_get_contents(); ob_end_clean(); return $gplwt_string; } // /** * Add FAQ and support information */ add_filter('plugin_row_meta', 'wp_gplwt_plugin_links', 10, 2); function wp_gplwt_plugin_links ($links, $file) { if ($file == plugin_basename(__FILE__)) { $links[] = '' . __('Donate', 'wp-gplwt') . ''; } return $links; } // function gtpartrat($par,$def) { // echo "par:".$par; if($par =='false'){ $par = false; //echo "teste:".$par; } if($par =='true'){ $par = true; //echo "teste:".$par; } if($par =='' || $par < 0){ $par = $def; //echo "teste:".$par; } //echo "teste2:".$par; return $par; } // display a list of posts with custom size thumbnails, using the post first image function getPostListThumbs($ptype='post',$dexcp=false,$orient='v',$imgo=false,$ttgo=false,$dtgo=false,$dtfrm=1,$categ='',$postnr=20,$linn=3,$divwid=300,$tbwid=40,$tbhig=40,$cp=4,$cs=4,$lwt=1,$tte='',$sptb=false,$tgtb=false,$ordm='',$ordf='ID',$metk='',$mett='n',$pgin='',$gptb=false,$pgnm='',$pgmx='',$ech=true,$gplwtdiv=''){ //echo "testando"; //error_reporting(E_ALL); //ini_set('display_errors', '1'); $ptype = gtpartrat($ptype,'post'); $dexcp = gtpartrat($dexcp,false); $orient = gtpartrat($orient,'v'); $imgo = gtpartrat($imgo,false); if($imgo==true):$ppimgo='true';else:$ppimgo='false';endif; $ttgo = gtpartrat($ttgo,false); if($ttgo==true):$ppttgo='true';else:$ppttgo='false';endif; $dtgo = gtpartrat($dtgo,false); if($dtgo==true):$ppdtgo='true';else:$ppdtgo='false';endif; $dtfrm = gtpartrat($dtfrm,1); $categ = gtpartrat($categ,''); $postnr = gtpartrat($postnr,20); $linn = gtpartrat($linn,3); $tbwid = gtpartrat($tbwid,40); $tbhig = gtpartrat($tbhig,40); $lwt = gtpartrat($lwt,1); $cp = gtpartrat($cp,4); $cs = gtpartrat($cs,4); $tte = gtpartrat($tte,''); if($tte==""):$pptte=0;endif; $sptb = gtpartrat($sptb,false); if($sptb==true):$ppsptb='true';else:$ppsptb='false';endif; $tgtb = gtpartrat($tgtb,false); if($tgtb==true):$pptgtb='true';else:$pptgtb='false';endif; $ordm = gtpartrat($ordm,'DESC'); $ordf = gtpartrat($ordf,'ID'); $metk = gtpartrat($metk,''); if($metk==""):$ppmetk=0;endif; $mett = gtpartrat($mett,'n'); $pgin = gtpartrat($pgin,''); $pgnm = gtpartrat($pgnm,1); $pgmx = gtpartrat($pgmx,''); $gptb = gtpartrat($gptb,false); $ech = gtpartrat($ech,true); $gplwtdiv = gtpartrat($gplwtdiv,''); /* $gplwtdiv $arrglpwt = array('orient' => $orient, 'imgo' => $imgo, 'ttgo' => $ttgo, 'dtgo' => $dtgo, 'dtfrm' => $dtfrm, 'categ' => $categ, 'postnr' => $postnr, 'linn' => $linn, 'tbwid' => $tbwid, 'tbhig' => $tbhig, 'cp' => $cp, 'cs' => $cs, 'lwt' => $lwt, 'tte' => $tte, 'sptb' => $sptb, 'tgtb' => $tgtb, 'ordm' => $ordm, 'ordf' => $ordf, 'metk' => $metk, 'mett' => $mett, 'ech' => $ech);*/ // $categ = category name - not required // $postnr = number of posts you want to display - not required /*$parflw = "orient='".$orient."'&imgo=".$ppimgo."&ttgo=".$ppttgo."&dtgo=".$ppdtgo."&dtfrm=".$dtfrm."&categ='".$categ."'&"; $parflw .= "postnr=".$postnr."&linn=".$linn."&tbwid=".$tbwid."&tbhig=".$tbhig."&lwt=".$lwt."&cp=".$cp."&"; $parflw .= "cs=".$cs."&tte='".$pptte."'&sptb=".$ppsptb."&tgtb=".$pptgtb."º='".$ordm."'&"; $parflw .= "ordf='".$ordf."'&metk='".$ppmetk."'&mett='".$mett."'";*/ $parflw = $ptype.",".$dexcp.",".$orient.",".$imgo.",".$ttgo.",".$dtgo.",".$dtfrm.",".$categ.","; $parflw .= $postnr.",".$linn.",".$divwid.",".$tbwid.",".$tbhig.",".$cp.","; $parflw .= $cs.",".$lwt.",".$tte.",".$sptb.",".$tgtb.",".$ordm.","; $parflw .= $ordf.",".$metk.",".$mett.",".$pgin; // $orient,$imgo,$ttgo,$dtgo,$dtfrm,$categ,$postnr,$linn,$divwid,$tbwid,$tbhig,$cp,$cs,$lwt,$tte,$sptb,$tgtb,$ordm,$ordf,$metk,$mett if($pgnm==1 && $gplwtdiv==""): $gplwtdiv = "gplwt_container_".uniqid(); endif; $htmlcod = '
'; $htmlcod .=""."\n"; //Teste if($tte!=""): $htmlcod .= ""."\n"; endif; $htmlcod .= ""."\n"; // $nextflg = false; $prevflg = false; //if (have_posts()) : global $post; $strquery = "post_type=".$ptype; // here we check if the user has chosen a category if($categ!=''){ $strquery .= "&category_name=". $categ; } else{ if($metk!=''){ $strquery .= "&meta_key=". $metk; } } // if($metk!=''){ if($mett!=''){ if($mett=='n'){ $strquery .= "&orderby=meta_value_num"; } else{ $strquery .= "&orderby=meta_value"; } } if($ordm!=''){ $strquery .= "&order=".$ordm; } } else{ if($ordf=='random'){ $strquery .= "&orderby=rand"; } else{ if($ordm!=''){ $strquery .= "&order=".$ordm; } // if($ordf!=''){ $strquery .= "&orderby=".$ordf; } } } $gplwt_myposts=get_posts($strquery."&numberposts=".$postnr); //echo $strquery."&numberposts=".$postnr; //echo "teste".sizeof($gplwt_myposts); if($pgin > 0){ $strquery .= "&posts_per_page=".$pgin."&paged=". $pgnm; } else{ $strquery .= "&posts_per_page=".$postnr; } $strquery .= "&post_status=publish"; //echo $strquery; //echo $strquery; // here we get the posts // if we want, we can display the number of registers found $ctxtr = 0; switch($dtfrm){ case 1: $dtdis = 'd/m/y'; break; case 2: $dtdis = 'm/d/y'; break; } switch($lwt){ case 1: $lwdis = false; break; case 2: $lwdis = true; break; } if($tgtb): $tgstr = "target='_blank'"; else: $tgstr = ""; endif; //query_posts($strquery); $gplwt_query = new WP_Query($strquery); //echo $strquery; // here we go in the loop $cntgplwt = 0; //while (have_posts()) : the_post(); $ipnr = 0;while ( $gplwt_query->have_posts() && $ipnr < $postnr) : $gplwt_query->the_post(); $cntgplwt = $cntgplwt + 1; // getting the first image of the post to make the thumb $args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID, 'orderby' => 'ID', 'order' => 'ASC' ); $attachments = get_posts($args); // here we set the variable for the attachment string $imgsrc = ""; if ($attachments): // here we take the first image and break the loop foreach ($attachments as $attachment) { // this brings the attachment array $imgobj = wp_get_attachment_image_src($attachment->ID); // if you use the line obove, you can call $imgobj[0] to get the image source // you can set the thumbnail dimensions, here we use 40 x 40 $imgsrc = wp_get_attachment_image($attachment->ID, array($tbwid,$tbhig), $icon = false); break; } endif; if($gptb): $thumbgplwt = wp_get_attachment_image_src ( get_post_thumbnail_id ( get_the_ID() ), 'thumbnail' ) ; if($thumbgplwt[0]!=""): $imgsrc = ".get_the_title()."; endif; endif; // here we start to build the return html code if($pgnm==1 && $pgin > 0): $pgmx = ceil(sizeof($gplwt_myposts)/$pgin); endif; if($cntgplwt==1 && $pgin > 0){ if($pgnm > 1): $pgplnm = $pgnm-1; //echo "pag".$pgnm . "de ".$pgmx; //echo "teste".$pgplnm; //$pgnm = $pgnm - 1; //$pgin = $pgmx/$pgnm; $parflw_p = $ptype.",".$dexcp.",".$orient.",".$imgo.",".$ttgo.",".$dtgo.",".$dtfrm.",".$categ.","; $parflw_p .= $postnr.",".$linn.",".$divwid.",".$tbwid.",".$tbhig.",".$cp.","; $parflw_p .= $cs.",".$lwt.",".$tte.",".$sptb.",".$tgtb.",".$ordm.","; $parflw_p .= $ordf.",".$metk.",".$mett.",".$pgin.",".$pgplnm.",".$pgmx.",".$gptb.",".$ech.",".$gplwtdiv; //echo "teste".$pgplnm; $prevflg = true; //$htmlcod .= ''; endif; if($pgnm < $pgmx): //echo "pag".$pgnm . "de ".$pgmx; //$pgnm = $pgnm + 1; //$pgin = $pgin + $pgin; $parflw_n = $ptype.",".$dexcp.",".$orient.",".$imgo.",".$ttgo.",".$dtgo.",".$dtfrm.",".$categ.","; $parflw_n .= $postnr.",".$linn.",".$divwid.",".$tbwid.",".$tbhig.",".$cp.","; $parflw_n .= $cs.",".$lwt.",".$tte.",".$sptb.",".$tgtb.",".$ordm.","; $parflw_n .= $ordf.",".$metk.",".$mett.",".$pgin.",".($pgnm+1).",".$pgmx.",".$gptb.",".$ech.",".$gplwtdiv; $nextflg = true; //$htmlcod .= ''; endif; } if($orient=="v"){ if($ctxtr == 0){ $htmlcod .= ""."\n"; } $ctxtr = $ctxtr + 1; // if the post has at least one image attached, we display it if(!$sptb): $htmlcod .= ""."\n"; endif; /*$htmlcod .= ""."\n"; $htmlcod .= ""."\n"; $htmlcod .= ""."\n"; */ if($lwdis){ $htmlcod .= ""."\n"; } if(!$imgo){ $htmlcod .= ""."\n"; } $htmlcod .= ""."\n"; } else{ // linn if($ctxtr == 0){ $htmlcod .= ""."\n"; } $ctxtr = $ctxtr + 1; $htmlcod .= ""."\n"; if($ctxtr == $linn){ $htmlcod .= ""."\n"; $ctxtr = 0; } } $ipnr++;endwhile; /* else: $htmlcod = ""."\n"; $htmlcod = ""."\n"; $htmlcod .= ""."\n"; endif;*/ //endif; $htmlcod .= ''; $htmlcod .= "

".$tte."

Previous
Next
"."\n"; if($imgsrc!=""): $htmlcod .= ""."\n"; $htmlcod .= $imgsrc; $htmlcod .= ""."\n"; endif; $htmlcod .= ""."\n"; $htmlcod .= ""; $htmlcod .= get_the_time('d/m/Y'); $htmlcod .= ""."\n"; $htmlcod .= "
"."\n"; if($dtgo): $htmlcod .= "

".get_the_time($dtdis)."

"; endif; if($ttgo): $htmlcod .= ""; $htmlcod .= get_the_title(); $htmlcod .= ""."\n"; endif; if($dexcp): $htmlcod .= "

".get_the_excerpt()."

"; endif; $htmlcod .= "
"."\n"; $htmlcod .= ""."\n"; // if the post has at least one image attached, we display it $htmlcod .= ""."\n"; if(!$sptb): $htmlcod .= ""."\n"; endif; endif; if($lwdis){ $htmlcod .= ""."\n"; } /*$htmlcod .= ""."\n"; $htmlcod .= ""."\n"; $htmlcod .= ""."\n"; */ if(!$imgo){ $htmlcod .= ""."\n"; } $htmlcod .= ""."\n"; $htmlcod .= ""."\n"; $htmlcod .= "
"."\n"; if($imgsrc!=""): $htmlcod .= ""."\n"; $htmlcod .= $imgsrc; $htmlcod .= ""."\n"; $htmlcod .= "
"."\n"; $htmlcod .= ""; $htmlcod .= get_the_time('d/m/Y'); $htmlcod .= ""."\n"; $htmlcod .= "
"."\n"; if($dtgo): $htmlcod .= "

".get_the_time($dtdis)."

"; endif; if($ttgo): $htmlcod .= ""; $htmlcod .= get_the_title(); $htmlcod .= ""."\n"; endif; if($dexcp): $htmlcod .= "

".get_the_excerpt()."

"; endif; $htmlcod .= "
"."\n"; $htmlcod .= "
"."\n"; $htmlcod .= "No registers found."."\n"; $htmlcod .= "
'; if($prevflg): $htmlcod .= ''; endif; if($nextflg): $htmlcod .= ''; endif; $htmlcod .= '
<>
"; if($ech): echo $htmlcod; else: return $htmlcod; endif; } function widget_getPostListThumbs($args) { extract($args); $options = get_option("widget_getPostListThumbs"); if (!is_array( $options )) { $options = array( 'ptype' => 'post', 'dexcp' => false, 'orient' => '', 'imgo' => '', 'ttgo' => '', 'dtgo' => '', 'dtfrm' => '', 'categ' => '', 'postnr' => '', 'linn' => '', 'divwid' => '', 'tbwid' => '', 'tbhig' => '', 'cp' => '', 'cs' => '', 'lwt' => '', 'tte' => '', 'sptb' => '', 'tgtb' => false, 'ordm' => '', 'ordf' => '', 'metk' => '', 'mett' => '', 'pgin' => '', 'gptb' => '' ); } //echo $before_widget; echo $before_title; echo $options['title']; echo $after_title; echo $after_widget; //Our Widget Content getPostListThumbs($options['ptype'],$options['dexcp'],$options['orient'],$options['imgo'],$options['ttgo'],$options['dtgo'],$options['dtfrm'],$options['categ'],$options['postnr'],$options['linn'],$options['divwid'],$options['tbwid'],$options['tbhig'],$options['cp'],$options['cs'],$options['lwt'],$options['tte'],$options['sptb'],$options['tgtb'],$options['metk'],$options['mett'],$options['pgin'],$options['gptb']); } function getPostListThumbs_control() { $options = get_option("widget_getPostListThumbs"); if (!is_array( $options )) { $options = array( 'ptype' => 'post', 'dexcp' => false, 'orient' => '', 'imgo' => '', 'ttgo' => '', 'dtgo' => '', 'dtfrm' => '', 'categ' => '', 'postnr' => '', 'linn' => '', 'divwid' => '', 'tbwid' => '', 'tbhig' => '', 'cp' => '', 'cs' => '', 'lwt' => '', 'tte' => '', 'sptb' => '', 'tgtb' => false, 'ordm' => '', 'ordf' => '', 'metk' => '', 'mett' => '', 'pgin' => '', 'gptb' => '' ); } if ($_POST['getPostListThumbs-Submit']) { $options['ptype'] = $_POST['getPostListThumbs-WidgetPtype']; $options['dexcp'] = $_POST['getPostListThumbs-WidgetDexcp']; $options['orient'] = $_POST['getPostListThumbs-WidgetOrient']; $options['imgo'] = $_POST['getPostListThumbs-WidgetImgo']; $options['ttgo'] = $_POST['getPostListThumbs-WidgetTtgo']; $options['dtgo'] = $_POST['getPostListThumbs-WidgetDtgo']; $options['dtfrm'] = $_POST['getPostListThumbs-WidgetDtfrm']; $options['categ'] = htmlspecialchars($_POST['getPostListThumbs-WidgetCateg']); $options['postnr'] = htmlspecialchars($_POST['getPostListThumbs-WidgetPostNr']); $options['linn'] = htmlspecialchars($_POST['getPostListThumbs-WidgetLinn']); $options['divwid'] = htmlspecialchars($_POST['getPostListThumbs-WidgetDivWid']); $options['tbwid'] = htmlspecialchars($_POST['getPostListThumbs-WidgetTbWid']); $options['tbhig'] = htmlspecialchars($_POST['getPostListThumbs-WidgetTbHig']); $options['cp'] = $_POST['getPostListThumbs-WidgetCp']; $options['cs'] = $_POST['getPostListThumbs-WidgetCs']; $options['lwt'] = $_POST['getPostListThumbs-WidgetLwt']; $options['tte'] = htmlspecialchars($_POST['getPostListThumbs-WidgetTte']); $options['sptb'] = htmlspecialchars($_POST['getPostListThumbs-WidgetSptb']); $options['tgtb'] = htmlspecialchars($_POST['getPostListThumbs-WidgetTgtb']); $options['tgtb'] = htmlspecialchars($_POST['getPostListThumbs-WidgetTgtb']); $options['ordm'] = htmlspecialchars($_POST['getPostListThumbs-WidgetOrdm']); $options['ordf'] = htmlspecialchars($_POST['getPostListThumbs-WidgetOrdf']); $options['metk'] = $_POST['getPostListThumbs-WidgetMetK']; $options['mett'] = $_POST['getPostListThumbs-WidgetMetT']; $options['pgin'] = $_POST['getPostListThumbs-WidgetPgin']; $options['gptb'] = $_POST['getPostListThumbs-WidgetGptb']; update_option("widget_getPostListThumbs", $options); } ?>





/>Post />Horizontal


/>Vertical />Horizontal


/>


/>


/>


/>


/>d/m/y />m/d/y


/>


/>








/>Numbers />Text








/>DESC />ASC





/>















/>
Image

Date

Title

Excerpt

/>
Image

Date

Title

Excerpt

'gplwt', 'description' => 'This is the GPLWT Plugin Widget.' ); /* Widget control settings. */ $control_ops = array( 'width' => 700, 'height' => 500, 'id_base' => 'gplwt-widget' ); /* Create the widget. */ $this->WP_Widget( 'gplwt-widget', 'GPLWT Widget', $widget_ops, $control_ops ); } function widget( $args, $instance ) { extract( $args ); //$instance = get_option("widget_getPostListThumbs"); if (!is_array( $options )) { $options = array( 'ptype' => 'post', 'dexcp' => false, 'orient' => '', 'imgo' => '', 'ttgo' => '', 'dtgo' => '', 'dtfrm' => '', 'categ' => '', 'postnr' => '', 'linn' => '', 'divwid' => '', 'tbwid' => '', 'tbhig' => '', 'cp' => '', 'cs' => '', 'lwt' => '', 'tte' => '', 'sptb' => '', 'tgtb' => false, 'ordm'=> '', 'ordf'=>'ID', 'metk' =>'', 'mett' => '', 'pgin' => '', 'gptb' => '' ); } /*echo $before_widget; echo $before_title; echo $options['title']; echo $after_title; echo $after_widget;*/ //Our Widget Content getPostListThumbs($instance['ptype'],$instance['dexcp'],$instance['orient'],$instance['imgo'],$instance['ttgo'],$instance['dtgo'],$instance['dtfrm'],$instance['categ'],$instance['postnr'],$instance['linn'],$instance['divwid'],$instance['tbwid'],$instance['tbhig'],$instance['cp'],$instance['cs'],$instance['lwt'],$instance['tte'],$instance['sptb'],$instance['tgtb'],$instance['ordm'],$instance['ordf'],$instance['metk'],$instance['mett'],$instance['pgin'],$instance['gptb']); } function update( $new_instance, $old_instance ) { $instance = $old_instance; /* Strip tags (if needed) and update the widget settings. */ $instance['ptype'] = $new_instance['ptype']; $instance['dexcp'] = $new_instance['dexcp']; $instance['orient'] = $new_instance['orient']; $instance['imgo'] = $new_instance['imgo']; $instance['ttgo'] = $new_instance['ttgo']; $instance['dtgo'] = $new_instance['dtgo']; $instance['dtfrm'] = $new_instance['dtfrm']; $instance['categ'] = htmlspecialchars($new_instance['categ']); $instance['postnr'] = htmlspecialchars($new_instance['postnr']); $instance['linn'] = htmlspecialchars($new_instance['linn']); $instance['divwid'] = htmlspecialchars($new_instance['divwid']); $instance['tbwid'] = htmlspecialchars($new_instance['tbwid']); $instance['tbhig'] = htmlspecialchars($new_instance['tbhig']); $instance['cp'] = $new_instance['cp']; $instance['cs'] = $new_instance['cs']; $instance['lwt'] = $new_instance['lwt']; $instance['tte'] = htmlspecialchars($new_instance['tte']); $instance['sptb'] = htmlspecialchars($new_instance['sptb']); $instance['tgtb'] = htmlspecialchars($new_instance['tgtb']); $instance['ordm'] = $new_instance['ordm']; $instance['ordf'] = $new_instance['ordf']; $instance['metk'] = $new_instance['metk']; $instance['mett'] = $new_instance['mett']; $instance['pgin'] = $new_instance['pgin']; $instance['gptb'] = htmlspecialchars($new_instance['gptb']); return $instance; } function form( $instance ) { /* Set up some default widget settings. */ $defaults = array( 'ptype' => 'post', 'dexcp' => false, 'orient' => 'v', 'imgo' => false, 'ttgo' => false, 'dtgo' => false, 'dtfrm' => 1, 'categ' => '', 'postnr' => 20, 'linn' => 3, 'tbwid' => 40, 'tbhig' => 40, 'cp' => 4, 'cs' => 4, 'lwt' => 1, 'tte' => '', 'sptb' => false, 'tgtb' => false, 'ordm'=>'', 'ordf'=>'ID', 'metk'=>'', 'mett'=>'n', 'pgin'=>'', 'gptb' => false ); $instance = wp_parse_args( (array) $instance, $defaults ); ?>

'v','imgo' => false,'ttgo' => false,'dtgo' => false,'dtfrm' => 1,'categ' => '','postnr' => 20,'linn' => 3,'tbwid' => 40,'tbhig' => 40,'cp' => 4,'cs' => 4,'lwt' => 1,'tte' => '','sptb' => false,'tgtb' => false ?>



/>Posts />Pages


/>Vertical />Horizontal


/>


/>


/>


/>


/>d/m/y />m/d/y


/>


/>








/>Numbers />Text










/>DESC />ASC





/>















/>
Image

Date

Title

Excerpt

/>
Image

Date

Title

Excerpt