Jquery cycle slides overlap on page-load on Wordpress Blog - jquery-cycle

I am using the wordpress plugin WP Featured Content Slider which uses the jquery.cycle.all.2.72.js. I am getting a really bizarre visual glitch. On page load, all the slides are shown on top of each other, then as the script cycles through each slide, sometimes it eventually fixes itself (until the page is reloaded).
I found another topic on this forum with the same problem and solution listed jQuery Cycle Slides overlap on page load
But I am not a technical person..can someone tell me where i need to put the codes suggested in the above solution in a wordpress self hosted blog.
Find the example here http://ramblingego.com
The Content Slider PHP Code is as below
<?php
$direct_path = get_bloginfo('wpurl')."/wp-content/plugins/wp-featured-content-slider";
?>
<script type="text/javascript">
jQuery('#featured_slider ul').cycle({
fx: '<?php $effect = get_option('effect'); if(!empty($effect)) {echo $effect;} else {echo "scrollLeft";}?>',
prev: '.feat_prev',
next: '.feat_next',
speed: 800,
timeout: <?php $timeout = get_option('timeout'); if(!empty($timeout)) {echo $timeout;} else {echo 4000;}?>,
pager: null
});
</script>
<style>
#featured_slider {
float: left;
margin: 10px 0px;
position: relative;
background-color: #<?php $bg = get_option('feat_bg'); if(!empty($bg)) {echo $bg;} else {echo "FFF";}?>;
border: 1px solid #<?php $border = get_option('feat_border'); if(!empty($border)) {echo $border;} else {echo "CCC";}?>;
width: <?php $width = get_option('feat_width'); if(!empty($width)) {echo $width;} else {echo "860";}?>px;
}
#featured_slider ul, #featured_slider ul li {
list-style: none !important;
border: none !important;
float: left;
margin: 10px;
width: <?php $width = get_option('feat_width'); if(!empty($width)) {echo $width;} else {echo "860";}?>px;
height: <?php $height = get_option('feat_height'); if(!empty($height)) {echo $height;} else {echo "210";}?>px;
}
#featured_slider .img_right {
float: left;
width: <?php $img_width = get_option('img_width'); if(!empty($img_width)) {echo $img_width;} else {echo "320";}?>px;
height: <?php $img_height = get_option('img_height'); if(!empty($img_height)) {echo $img_height;} else {echo "200";}?>px;
margin-left: 20px;
}
#featured_slider .img_right img {
width: <?php $img_width = get_option('img_width'); if(!empty($img_width)) {echo $img_width;} else {echo "320";}?>px;
height: <?php $img_height = get_option('img_height'); if(!empty($img_height)) {echo $img_height;} else {echo "200";}?>px;
}
#featured_slider .content_left {
float: left;
color: #<?php $text_color = get_option('text_color'); if(!empty($text_color)) {echo $text_color;} else {echo "333";}?>;
width: <?php $text_width = get_option('text_width'); if(!empty($text_width)) {echo $text_width;} else {echo "450";}?>px;
}
#featured_slider .content_left p {
line-height: 22px !important;
color: #<?php $text_color = get_option('text_color'); if(!empty($text_color)) {echo $text_color;} else {echo "333";}?>;
}
#featured_slider .content_left h2 {
font-size: 20px !important;
margin-bottom: 20px;
}
#featured_slider .feat_prev {
background: transparent url(<?php echo $direct_path;?>/images/sprite.png) no-repeat;
background-position: 0px 0px;
width: 17px;
z-index: 10;
height: 16px;
position: absolute;
left: 20px;
cursor: pointer;
bottom: 30px;
float: left;
}
#featured_slider .feat_prev:hover {
background-position: 0px -16px;
}
#featured_slider .feat_next {
background: transparent url(<?php echo $direct_path;?>/images/sprite.png) no-repeat;
background-position: -17px 0px;
width: 17px;
z-index: 10;
height: 16px;
position: absolute;
left: 40px;
bottom: 30px;
cursor: pointer;
}
#featured_slider .feat_next:hover {
background-position: -18px -16px;
}
</style>
<div id="featured_slider">
<ul id="slider">
<?php
$sort = get_option('sort'); if(empty($sort)){$sort = "post_date";}
$order = get_option('order'); if(empty($order)){$order = "DESC";}
$limit = get_option('limit'); if(empty($limit)){$limit = 350;}
$points = get_option('points'); if(empty($points)){$points = "...";}
$post_limit = get_option('limit_posts'); if(empty($limit_posts)){$limit_posts = "-1";}
global $wpdb;
global $post;
$args = array( 'meta_key' => 'feat_slider', 'meta_value'=> '1', 'suppress_filters' => 0, 'post_type' => array('post', 'page'), 'orderby' => $sort, 'order' => $order, 'numberposts'=> $post_limit);
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post);
$custom = get_post_custom($post->ID);
$thumb = get_wp_generated_thumb("feat_slider");
?>
<li><div class="content_left"><h2><?php the_title();?></h2><?php echo cut_text_feat(get_the_content(), $limit, $points);?></div><div class="img_right"><img src="<?php echo $thumb;?>" /></div></li>
<?php endforeach; ?>
</ul>
<div class="feat_next"></div>
<div class="feat_prev"></div>
</div>

If you can't output all the slides with display:hidden you can use jquery to hide all of them (except the first one) and then the cycle plugin should do the rest.
Like this:
<script type="text/javascript">
jQuery('#featured_slider ul>li:gt(0)').hide(function() {
jQuery('#featured_slider ul').cycle({
fx: '<?php $effect = get_option('effect'); if(!empty($effect)) {echo $effect;} else {echo "scrollLeft";}?>',
prev: '.feat_prev',
next: '.feat_next',
speed: 800,
timeout: <?php $timeout = get_option('timeout'); if(!empty($timeout)) {echo $timeout;} else {echo 4000;}?>,
pager: null
});
});

Related

Can't add 2 same modules on Joomla

I am a beginner programmer so I do not master certain parts very well.
I developed a joomla module that allows you to display an accordion menu according to the level you entered in the admin interface for my company's website. My module is made of a php file containing also the style part and the script (the links to the Jquery scripts) and an XML file.
My problem is that as soon as I try to add on the same page 2 articles using the same module the page just crash and I don't know why, is there any kind soul that could help me to figure out what is the problem please ?
(also it's my first time using Stack Overflow I'm sorry if I am using it in a wrong way)
Here is my code (without the database connexion and the whole path to the script) :
<?php
//space dedicated to the connexion to the database
$idMod=$module->id; //Idendifiant du module a intéger en cas de script dans le nom des paramètres
$id.$idMod=$params->get('base'); //We retrieve the parameters
//We check to connexion
if($mysqli->connect_error){
die('Erreur : ' .$conn->connect_error);
}
function HasChildAccordion($mysqli, $Num, $idModule){ //lets you know if there are children for the associated menu
$Nbenfant.$idMod=0;
$Enfant.$idMod= "SELECT id FROM sgc_menu WHERE parent_id=$Num AND published=1";
$exec=mysqli_query($mysqli, $Enfant.$idMod);
while($result=mysqli_fetch_array($exec, MYSQLI_ASSOC)){
$Nbenfant.$idMod= $Nbenfant.$idMod+1;
}
$Nbenfants.$idMod=$Nbenfant.$idMod;
return $Nbenfants.$idMod;
}
function getChildAccordion($mysqli, $bla, $idModule){ //Recursive function to display menu names and retrieve submenus
$query.$idMod="SELECT link, title, level, parent_id, id FROM sgc_menu WHERE id=$bla AND published=1";
$exec=mysqli_query($mysqli, $query.$idMod);
while ($TOTO = mysqli_fetch_assoc($exec)) {
$test=HasChildAccordion($mysqli, $TOTO['id'], $idMod);
if ( $test!=0){
//echo '<a class="myNav-link ui-accordion-trigger'.$idMod.'" href="'.$TOTO['link'].'">'.$TOTO['title'].'</a>';
echo '<a class="myNav-link ui-accordion-trigger" href="'.$TOTO['link'].'">'.$TOTO['title'].'</a>';
// echo '<div class="myNav-content ui-accordion-content'.$idMod.'">' ;
echo '<div class="myNav-content ui-accordion-content">' ;
$query2="SELECT id, title, level, parent_id, link FROM sgc_menu WHERE parent_id=$bla AND published=1";//On récupères les enfants
$exec2=mysqli_query($mysqli, $query2);
while($result=mysqli_fetch_array($exec2, MYSQLI_ASSOC)){ // For every children we apply the function getChildAccordion;
// echo '<div class="subNav ui-accordion'.$idMod.'">';
echo '<div class="subNav ui-accordion">';
getChildAccordion($mysqli, $result['id'], $idMod); //we display children's children
echo '</div>' ;
}
echo '</div>' ;
} else {
//echo '<div class="myNav-item ui-accordion-item'.$idMod.'">';
echo '<div class="myNav-item ui-accordion-item">';
echo '<a class="clicable" href="'.$TOTO['link'].'">'.$TOTO['title'].'</a>';
echo '</div>';
}
}
// $Nbenfant=0;
}
//echo '<div class="myNav ui-accordion'.$idMod.'">';
echo '<div class="myNav ui-accordion">';
getChildAccordion($mysqli, $id.$idMod, $idMod); //the function is called with the menu chosen in the configuration of the module
echo '</div>';
?>
<script src="http://.../jquery.min.js"></script>
<script src="http://.../jquery.simpleAccordion.min.js"></script>
<script>
$(document).ready(function() {
$('.ui-accordion').simpleAccordion ({
item :'.ui-accordion-item',
trigger :'.ui-accordion-trigger',
content :'.ui-accordion-content',
active :'active',
autoclose:true,
multiple :true,
speed:500 });
});
$(document).ready(function() {
$('.SubNav').simpleAccordion ({
trigger :'.subui-accordion-trigger',
content :'.subui-accordion-content',
active:'active',
autoclose:true,
multiple:true,
speed:1000});
});
</script>
//
<style>
<?php
$colorbg=$params->get('colorbg');
$colortext=$params->get('colortext');
$colorHover=$params->get('colorHover');
$FontSize=$params->get('FontSize');
$colortextClickable=$params->get('colortextClickable');
?>
.myNav {
position: static;
display:block;
background-color: <?php echo $colorbg ; ?>;
padding:2% 2% 2% 2%;
margin: 2% 2% 2% 5%;
border-radius: 4px;
border: 1px solid #1c4281;
margin: 5px 22px 18px 22px;
padding-top: 10px;
box-shadow: 7px 7px 5px 0px rgba(28, 66, 129, 0.75);
font-family: Kepler_296;
}
.myNav a{
position : static;
display:inline;
color:<?php echo $colortext ; ?>;
font-family: Kepler_296;
}
.myNav-item:not(:first-child) {
border-top:1px solid #fff;
}
.myNav-link {
position:static;
display:block;
}
.myNav-content {
position:static;
display:block;
padding:2% 2% 2% 2%;
margin: 2% 2% 2% 2%;
}
.subNav{
justify-content:space-around;
}
.ui-accordion-content, .subui-accordion-content{ display:none; }
.active > .ui-accordion-content, .active> .subui-accordion-content {
display:block;
}
a.clicable {
color:<?php echo $colortextClickable ; ?>;
font-family: Kepler_296;
font-size: <?php echo $FontSize ; ?>px;
}
a.clicable:hover{
color:<?php echo $colorHover ; ?>;
font-weight: bold;
}
.ui-accordion-trigger{
font-size: <?php echo $FontSize ; ?>px;
cursor:pointer;
position: static;
display: inline;
}
.ui-accordion-trigger::after {
margin: -15px 0px 0px 2px;
content:'\1F892';
position:static;
display: inline;
float:right;
top:50%;
font-size: 40px;
transition-duration: 0.5s;
}
.active> .ui-accordion-trigger::after{
margin: -15px 0px 0px 20px;
position: static;
display: inline;
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-o-transform: rotate(90deg);
transform: rotate(90deg);
transition-duration: 0.8s;
}
</style>
I thought the problem came from a variable but I sincerly have no idea
I cannot debug the whole thing.
But here's a couple of things I noticed:
$query.$idMod =
is a funny way to put the sql into $idMod. And it does nothing to $query. Also, it is beyond confusing.
What you wanted to achieve is most likely to declare a different variable name for your query for each instance of the module.
This would be achieved with:
${'query'.$idMod} =
but you don't need it. Most likely, the cause for the module content repeating is the cache, try disabling it.
Finally, you might want to look into css variables, the stylesheet you pasted would benefit from using them.

laravel dompdf export not export all content of my view

Im currently using laravel 9, laravel dompdf package for export my file , this the pdf file igot , no content at all. the data i pass did not display in the PDF. ::
But when I just open it as view , the data pass properly and the css work nice. This is how it looks like :
Here is my code on the View:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap demo</title>
</head>
<style>
* {
box-sizing: border-box;
margin:0;
padding:0;
}
body {
background:#DDD;
}
div.container {
max-width: 1350px;
margin: 0 auto;
overflow: hidden
}
.upcomming {
font-size: 45px;
text-transform: uppercase;
border-left: 14px solid rgba(255, 235, 59, 0.78);
padding-left: 12px;
margin: 18px 8px;
}
.container .item {
width: 48%;
float: left;
padding: 0 20px;
background: #fff;
overflow: hidden;
margin: 10px
}
.container .item-right, .container .item-left {
float: left;
padding: 20px
}
.container .item-right {
padding: 79px 0px;
margin-right: 20px;
width: 25%;
position: relative;
height: 286px;
text-align: center;
}
.container .item-right .up-border, .container .item-right .down-border {
padding: 14px 15px;
background-color: #ddd;
border-radius: 50%;
position: absolute
}
.container .item-right .up-border {
top: -8px;
right: -35px;
}
.container .item-right .down-border {
bottom: -13px;
right: -35px;
}
.container .item-right .num {
font-size: 50px;
color: #111
}
.container .item-right .day, .container .item-left .event {
color: #555;
font-size: 15px;
margin-bottom: 9px;
}
.container .item-right .day {
text-align: center;
font-size: 25px;
}
.container .item-left {
width: 71%;
padding: 34px 0px 19px 46px;
border-left: 3px dotted #999;
}
.container .item-left .title {
color: #111;
font-size: 34px;
margin-bottom: 12px
}
.container .item-left .sce {
margin-top: 5px;
display: block
}
.container .item-left .sce .icon, .container .item-left .sce p,
.container .item-left .loc .icon, .container .item-left .loc p{
float: left;
word-spacing: 5px;
letter-spacing: 1px;
color: #888;
margin-bottom: 10px;
}
.container .item-left .sce .icon, .container .item-left .loc .icon {
margin-right: 10px;
font-size: 20px;
color: #666
}
.container .item-left .loc {display: block}
.fix {clear: both}
.container .item .tickets, .booked, .cancel{
color: #fff;
padding: 6px 14px;
float: right;
margin-top: 10px;
font-size: 18px;
border: none;
cursor: pointer
}
.container .item .tickets {background: #777}
.container .item .booked {background: #3D71E9}
.container .item .cancel {background: #DF5454}
.linethrough {text-decoration: line-through}
</style>
<body>
<div class="container">
<h1 class="upcomming">Event Tickets</h1>
#php ($i=1)
#foreach ($tickets as $key=> $ticket)
<div class="item">
<div class="item-right">
<h2 class="num"> {{ $ticket->ticket_no }}</h2>
<p class="day">Ticket No.</p>
<span class="up-border"></span>
<span class="down-border"></span>
</div> <!-- end item-right -->
<div class="item-left">
<p class="event">{{ $ticket->GiftGiving->name }}</p>
<h2 class="title">{{ $ticket->name }}</h2>
<div class="sce">
<p>{{Carbon\Carbon::parse($ticket->GiftGiving->start_at )->isoFormat('LL') }}<br/> {{ Carbon\Carbon::parse($ticket->GiftGiving->start_at )->isoFormat('h:mm A') }}</p>
</div>
<div class="fix"></div>
<div class="loc">
<p>{{ $ticket->GiftGiving->venue }}</p>
</div>
<div class="fix"></div>
<button class="booked">Batch No. {{ $ticket->GiftGiving->batch_no}}</button>
</div> <!-- end item-right -->
</div> <!-- end item -->
<!--Set limitation of printing only 5 ticket per page-->
#if ($i % 6 === 0)
<div style="page-break-after: always;"></div>
#endif
#php ($i++)
#endforeach
</div>
</body>
</html>
Controller
public function GenerateTicket($code)
{
# Retrieve the records using $code
$GiftGiving = GiftGiving::where('code', $code)->firstOrFail();
$tickets = GiftGivingBeneficiary::where('gift_giving_id', $GiftGiving->id)->get();
# Users can only access their own charity's records
if ($GiftGiving->charitable_organization_id == Auth::user()->charitable_organization_id) {
# Must have at least one beneficiary before generating tickets
if ($tickets->count() < 1) {
$toastr = array(
'message' => 'Gift Giving must have at least one (1) beneficiary first before generating tickets',
'alert-type' => 'error'
);
return redirect()->back()->with($toastr);
}
# Retrieve the last batch no. from the gift giving.
$batch_no = $GiftGiving->batch_no;
# Increment Batch no. by +1
$GiftGiving->update([
'last_downloaded_by' => Auth::id(),
'batch_no' => $batch_no + 1,
]);
# Audit Logs Creation
$log = new AuditLog;
$log->user_id = Auth::user()->id;
$log->action_type = 'GENERATE PDF';
$log->charitable_organization_id = Auth::user()->charitable_organization_id;
$log->table_name = 'Gift Giving';
$log->record_id = $GiftGiving->code;
$log->action = 'Charity Admin generated tickets for the Gift Giving [' . $GiftGiving->name . '] with batch no. ' . $GiftGiving->batch_no . '.';
$log->performed_at = Carbon::now();
$log->save();
# Send Notification to each user in their Charitable Organizations
$users = User::where('charitable_organization_id', Auth::user()->charitable_organization_id)->where('status', 'Active')->get();
foreach ($users as $user) {
$notif = new Notification;
$notif->code = Str::uuid()->toString();
$notif->user_id = $user->id;
$notif->category = 'Gift Giving';
$notif->subject = 'Generated Tickets';
$notif->message = Auth::user()->role . ' ' . Auth::user()->info->first_name . ' ' .
Auth::user()->info->last_name . ' has generated tickets for [' . $GiftGiving->name . '] with batch no. ' .
$GiftGiving->batch_no . '.';
$notif->icon = 'mdi mdi-ticket';
$notif->color = 'info';
$notif->created_at = Carbon::now();
$notif->save();
}
// return view('charity.gifts.generate_ticket', compact('tickets'));
$pdf = PDF::loadView('charity.gifts.generate_ticket', compact('tickets'));
return $pdf->download($GiftGiving->name . ' - No. ' . $GiftGiving->batch_no . '.pdf');
} else {
$toastr = array(
'message' => 'Users can only access their own charity records.',
'alert-type' => 'error'
);
return redirect()->back()->with($toastr);
}
}
Hope somebody can point out what did i miss, thankyou in advance . all suggest/answer are highly appreciated.
dompdf is really picky about CSS and styles... but first, you should always put your <style> tags inside the <head> tag of the document. Without putting it there, there will be inconsistencies in how different browsers render the content, and that includes headless systems and domPDF.
So put your <style> tag in the <head> tags, and see if that helps resolve the issue, and if not, try converting your styles to tables with styling, as dompdf seems to do better with tables than divs.
you should care about syntax:
#php $i = 1; #endphp
#php $i++; #endphp

How to view custom log files using Log Viewer in Laravel

I am using Laravel Log Reader
for viewing log files. It works fine.
But I also have other log files, how can I view them usig this viewer?
This package matching specific file pattern logs/laravel-*.log .So your mentioned log file doesn't match. This package doesn't have configuration to change it at present. But still if you want to view your own log files then you can override method and create your own view file.
I can provide you some basic idea and make sure i haven't written code in super clean.This is to get some idea
Custom class which is extended
<?php
namespace App\Helper;
class LaravelLogReader extends \Haruncpi\LaravelLogReader\LaravelLogReader
{
public function getLogFileDates()
{
$dates = [];
$files = glob(storage_path('logs/*.log'));
$files = array_reverse($files);
foreach ($files as $path) {
$fileName = basename($path);
array_push($dates, $fileName);
}
return $dates;
}
public function get()
{
$availableDates = $this->getLogFileDates();
if (count($availableDates) == 0) {
return response()->json([
'success' => false,
'message' => 'No log available'
]);
}
$configDate = $this->config['date'];
if ($configDate == null) {
$configDate = $availableDates[0];
}
if (!in_array($configDate, $availableDates)) {
return response()->json([
'success' => false,
'message' => 'No log file found with selected date ' . $configDate
]);
}
$pattern = "/^\[(?<date>.*)\]\s(?<env>\w+)\.(?<type>\w+):(?<message>.*)/m";
$fileName = $configDate;
$content = file_get_contents(storage_path('logs/' . $fileName));
preg_match_all($pattern, $content, $matches, PREG_SET_ORDER, 0);
$logs = [];
foreach ($matches as $match) {
$logs[] = [
'timestamp' => $match['date'],
'env' => $match['env'],
'type' => $match['type'],
'message' => trim($match['message'])
];
}
$date = $fileName;
$data = [
'available_log_dates' => $availableDates,
'date' => $date,
'filename' => $fileName,
'logs' => $logs
];
return response()->json(['success' => true, 'data' => $data]);
}
}
and view file which is copied from library view .i have named it as log.blade.php
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Log Reader</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>
<script>
var angularUrl = '{{asset('laravel-log-reader/angular.min.js')}}';
window.angular || document.write('<script src="' + angularUrl + '">\x3C/script>')
</script>
<style>
body {
margin: 0;
padding: 0;
background: #f4f4f4;
font-family: sans-serif;
}
.btn {
text-decoration: none;
background: antiquewhite;
padding: 5px 12px;
border-radius: 25px;
}
header {
min-height: 30px;
display: flex;
justify-content: space-between;
align-items: center;
padding: 15px;
background: #3F51B5;
position: fixed;
left: 0;
right: 0;
top: 0;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
}
header .btn_clear_all {
background: #de4f4f;
color: #fff;
}
header .name {
font-size: 25px;
font-weight: 500;
color: white;
}
.content {
margin-top: 65px;
padding: 15px;
background: #fff;
min-height: 100px;
}
.content .date_selector {
min-height: 26px;
min-width: 130px;
border: 1px solid #ddd;
border-radius: 4px;
}
.top_content {
display: flex;
justify-content: space-between;
align-items: center;
}
.top_content .top_content_left {
display: flex;
}
.top_content .top_content_left .log_filter {
display: flex;
align-items: center;
margin-left: 15px;
}
.top_content .top_content_left .log_filter .log_type_item {
margin-right: 4px;
background: #eae9e9;
max-height: 20px;
font-size: 11px;
box-sizing: border-box;
padding: 4px 6px;
cursor: pointer;
}
.top_content .top_content_left .log_filter .log_type_item.active {
background: #2f2e2f;
color: white;
}
.top_content .top_content_left .log_filter .log_type_item.clear {
background: #607D8B;
color: white;
}
table {
border: 1px solid #ccc;
border-collapse: collapse;
margin: 0;
padding: 0;
width: 100%;
}
table tr {
border: 1px solid #e8e8e8;
padding: 5px;
}
table tr:hover {
background: #f4f4f4;
}
thead tr td {
background: #717171;
color: #fff;
}
table th,
table td {
padding: 5px;
font-size: 14px;
color: #666;
}
table th {
font-size: 14px;
letter-spacing: 1px;
text-transform: uppercase;
}
#media screen and (max-width: 700px) {
.top_content {
flex-direction: column;
}
.top_content .top_content_left {
flex-direction: column;
}
.top_content .log_filter {
flex-wrap: wrap;
}
.top_content .log_filter .log_type_item {
margin-bottom: 3px;
}
}
#media screen and (max-width: 600px) {
header {
flex-direction: column;
}
header .name {
margin-bottom: 20px;
}
.content {
margin-top: 90px;
}
.btn {
font-size: 13px;
}
.dt_box,
.selected_date {
text-align: center;
}
.responsive_table {
max-width: 100%;
overflow-x: auto;
}
table {
border: 0;
}
table thead {
display: none;
}
table tr {
border-bottom: 2px solid #ddd;
display: block;
margin-bottom: 10px;
}
table td {
border-bottom: 1px dotted #ccc;
display: block;
font-size: 15px;
}
table td:last-child {
border-bottom: 0;
}
table td:before {
content: attr(data-label);
float: left;
font-weight: bold;
text-transform: uppercase;
}
}
.badge {
padding: 2px 8px;
-webkit-border-radius: 25px;
-moz-border-radius: 25px;
border-radius: 25px;
font-size: 11px;
}
.badge.info {
background: #6bb5b5;
color: #fff;
}
.badge.warning {
background: #f7be57;
}
.badge.critical {
background: #de4f4f;
color: #fff;
}
.badge.emergency {
background: #ff6060;
color: white;
}
.badge.notice {
background: bisque;
}
.badge.debug {
background: #8e8c8c;
color: white;
}
.badge.alert {
background: #4ba4ea;
color: white;
}
.badge.error {
background: #c36a6a;
color: white;
}
</style>
</head>
<body ng-controller="LogCtrl">
<header>
<div class="name">#{{ title }}</div>
<div class="actions">
<a class="btn btn_clear_all" href="#" ng-click="clearAll()">Clear All</a>
<a class="btn" href="{{url(config('laravel-log-reader.admin_panel_path'))}}">Goto Admin Panel</a>
<a class="btn" href="https://laravelarticle.com/laravel-log-reader" title="Laravel Log Reader">Doc</a>
</div>
</header>
<section class="content">
<div class="top_content">
<div class="top_content_left">
<div>
<p class="selected_date" style="font-size: 14px;"><strong>
<span ng-show="response.success">Showing Logs: #{{data.date}}</span>
<span ng-hide="response.success">#{{response.message}}</span>
</strong></p>
</div>
<div class="log_filter">
<div class="log_type_item" ng-class="selectedType==tp?'active':''"
ng-repeat="tp in logTypes track by $index"
ng-click="filterByType(tp)">#{{ tp }}
</div>
<div class="log_type_item clear" ng-show="selectedType" ng-click="selectedType=undefined">CLEAR FILTER
</div>
</div>
</div>
<div class="top_content_right">
<p class="dt_box">Select Date: <select class="date_selector" ng-model="selectedDate"
ng-change="init(selectedDate)">
<option ng-repeat="dt in data.available_log_dates"
value="#{{ dt }}">#{{ dt }}
</option>
</select>
</p>
</div>
</div>
<div>
<div class="responsive_table">
<table>
<thead>
<tr>
<td width="140">Timestamp</td>
<td width="120">Env</td>
<td width="120">Type</td>
<td>Message</td>
</tr>
</thead>
<tr ng-repeat="log in data.logs |filter: selectedType track by $index">
<td>#{{ log.timestamp }}</td>
<td>#{{log.env}}</td>
<td><span class="badge #{{ log.type.toLowerCase() }}">#{{ log.type }}</span></td>
<td>#{{ log.message }}</td>
</tr>
</table>
</div>
</div>
<script>
var myApp = angular.module("myApp", []);
myApp.controller("LogCtrl", function ($scope, $http) {
$scope.title = "Log Reader";
$scope.selectedType = undefined;
$scope.logTypes = ['INFO', 'EMERGENCY', 'CRITICAL', 'ALERT', 'ERROR', 'WARNING', 'NOTICE', 'DEBUG'];
var originalData = null;
$scope.init = function (date) {
var url = '';
if (date !== '' && date !== undefined) {
url = '{{url(config('laravel-log-reader.api_route_path'))}}?date=' + date
} else {
url = '{{url("custom-logger")}}'
}
alert(url);
$http.get(url)
.success(function (data) {
$scope.response = data;
$scope.data = data.data;
originalData = data.data;
})
};
$scope.init();
$scope.filterByType = function (tp) {
$scope.selectedType = tp
};
$scope.clearAll = function () {
if (confirm("Are you sure?")) {
var url = '{{url(config('laravel-log-reader.view_route_path'))}}'
$http.post(url, {'clear': true})
.success(function (data) {
if (data.success) {
alert(data.message);
$scope.init();
}
})
}
}
})
</script>
</section>
</body>
</html>
And add two routes
Route::get('custom-logger', function () {
$laravelLogReader=new \App\Helper\LaravelLogReader();
return $laravelLogReader->get();
});
Route::get('/log-viewer', function () {
return view('log');
});
Note: this not fully optimized code but you can write it in better way.This is only to show you can override the package
Another package you can use
Ref:https://github.com/rap2hpoutre/laravel-log-viewer
This package will read all log files and i have tested it it works fine

How to load wp-login.php on front-end in wordpress?

I want to load this login page as shown below on the front page of my website when a login button is clicked and I don't want to use wp_login_form() because I want to load the social login icons that the plugin loads on the wp-login.php page.
I know it can be done using Ajax and I'm not able to achieve it because of my unfamiliarity with the language. Any help on how WordPress loads the wp-login.php page as shown in the image below?
This is not trivial, and you are right, you'll need to use AJAX for this.
I'll first add the files and code in them and then try to explain as I go.
header.php
This can obviously be different for you, but you'll need to see the structure. You can remove the registration part if you want.
<header id="main_header" class="clearfix">
<div class="top_bar">
<div class="container">
<div class="ajax_login">
<form id="login" action="login" method="post">
<h1><?php esc_attr_e('User login','yourtheme') ?></h1>
<p class="status"></p>
<input id="username" type="text" name="username" placeholder="<?php esc_attr_e('Username','yourtheme') ?>">
<input id="password" type="password" name="password" placeholder="<?php esc_attr_e('Password','yourtheme') ?>">
<div class="forgotten_box">
<a class="lost" href="<?php echo esc_url(wp_lostpassword_url()); ?>"><?php esc_attr_e('Lost your password?','yourtheme') ?></a>
</div>
<input class="submit_button" type="submit" value="Login" name="submit">
<?php wp_nonce_field( 'ajax-login-nonce', 'security' ); ?>
</form>
<div class="ajax_login_overlay"></div>
<?php if (is_user_logged_in()):?>
<a class="login_button" href="<?php echo wp_logout_url( home_url() ); ?>"><?php esc_attr_e('Logout','yourtheme') ?></a>
<?php else: ?>
<a class="login_button" id="show_login" href=""><?php esc_attr_e('Login','yourtheme') ?></a>
<?php endif; ?>
</div>
<?php if (!is_user_logged_in()):?>
<div class="register">
<a class="lost" href="<?php echo esc_url(wp_registration_url()); ?>" id="show_register"><?php esc_attr_e('Register','yourtheme') ?></a>
<form method="post" name="st-register-form" id="register_form">
<h2 class="register-heading"><?php esc_html_e( 'Register', 'yourtheme' ); ?></h2>
<div id="registration-error-message">
</div>
<div class="field">
<input type="text" autocomplete="off" name="username" id="yourtheme_register-username" placeholder="<?php esc_html_e( 'Username', 'yourtheme' ); ?>" />
</div>
<div class="field">
<input type="text" autocomplete="off" name="mail" id="yourtheme_register-email" placeholder="<?php esc_html_e( 'Email', 'yourtheme' ); ?>" />
</div>
<div class="field">
<input type="text" autocomplete="off" name="fname" id="yourtheme_register-fname" placeholder="<?php esc_html_e( 'First Name', 'yourtheme' ); ?>" />
</div>
<div class="field">
<input type="text" autocomplete="off" name="lname" id="yourtheme_register-lname" placeholder="<?php esc_html_e( 'Last Name', 'yourtheme' ); ?>" />
</div>
<div class="frm-button">
<input type="button" id="register-me" value="Register" />
</div>
</form>
</div>
<?php endif; ?>
</div>
</div>
</header>
Basically a form that you'll submit with AJAX. Nothing special there.
css to go with that (unfinished, and you'll want to change it to something that suits you)
/*------------------------ AJAX login -------------------------*/
.top_bar{
text-align: right;
}
.top_bar .ajax_login{
display: inline-block;
margin-right: 10px;
}
.top_bar .ajax_login_overlay{
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgb(0,0,0);
background: rgba(0,0,0,0.5);
display: none;
cursor: default;
z-index: 101;
transform: translateZ(1px);
}
.top_bar .ajax_login form#login{
display: none;
background-color: #FFFFFF;
position: fixed;
top: 50%;
margin-top: -117px;
z-index: 999;
left: 50%;
margin-left: -200px;
cursor: default;
}
.top_bar .ajax_login form#login h1{
color: #656565;
background: #eee;
font-weight: 700;
text-transform: uppercase;
font-size: 15px;
padding: 2px 20px;
text-align: left;
}
.top_bar .ajax_login form#login p.status{
display: none;
padding: 0 20px;
margin-bottom: 12px;
}
.top_bar .ajax_login form#login input#username,
.top_bar .ajax_login form#login input#password{
margin: 10px 20px;
width: 400px;
display: block;
}
.top_bar .ajax_login form#login .forgotten_box{
display: inline-block;
padding: 3px 20px 0 20px;
}
.top_bar .ajax_login form#login .forgotten_box .lost{
display: block;
padding: 5px;
padding-left: 0;
margin-bottom: 0;
}
.top_bar .ajax_login form#login input.submit_button{
padding: 15px;
border-radius: 4px;
font-weight: 700;
text-transform: uppercase;
margin-right: 20px;
float: right;
cursor: pointer;
-webkit-transition: all 180ms ease-in;
-moz-transition: all 180ms ease-in;
-o-transition: all 180ms ease-in;
transition: all 180ms ease-in;
}
.top_bar .ajax_login .login_overlay{
height: 100%;
width: 100%;
background-color: #F6F6F6;
opacity: 0.9;
position: fixed;
z-index: 998;
}
.top_bar .ajax_login .login_button,
.top_bar .register a{
display: inline-block;
color: #0c0f0b;
font-size: 12px;
font-weight: 700;
line-height: 30px;
}
.top_bar .ajax_login .login_button:hover{
color: #d84949;
}
.top_bar .register{
display: inline-block;
}
/*------------------------ AJAX register -------------------------*/
.top_bar .register #register_form{
display: none;
background-color: #FFFFFF;
position: fixed;
top: 50%;
margin-top: -117px;
z-index: 999;
left: 50%;
margin-left: -200px;
cursor: default;
}
.top_bar .register #register_form input[type="text"]{
margin: 10px 20px;
width: 400px;
display: block;
background: #f2f2f2;
border: 0;
font-family: 'Roboto', sans-serif;
color: rgb(115, 115, 115);
color: rgba(115, 115, 115, 0.5);
font-size: 14px;
font-weight: 400;
line-height: 20px;
text-align: left;
font-style: italic;
}
.top_bar .register #register_form .register-heading{
background: #be0017;
font-family: Arial;
color: #ffffff;
font-size: 16px;
line-height: 12px;
font-weight: 700;
letter-spacing: 0.64px;
text-align: left;
padding:15px 20px;
text-transform:uppercase;
}
functions.php
You can add this in functions.php or in a separate file you include in your functions.php file. It's the AJAX callback functions, localization for your admin-ajax.php etc.
<?php
/********* AJAX Login ***********/
function yourtheme_ajax_login_init(){
wp_register_script('ajax-login-script', get_template_directory_uri() . '/js/ajax-login-script.js', array('jquery') );
wp_enqueue_script('ajax-login-script');
wp_localize_script( 'ajax-login-script', 'ajax_login_object', array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'redirecturl' => home_url(),
'loadingmessage' => esc_html__('Sending user info, please wait...', 'yourtheme')
));
// Enable the user with no privileges to run ajax_login() in AJAX
add_action( 'wp_ajax_nopriv_ajaxlogin', 'ajax_login' );
}
// Execute the action only if the user isn't logged in
if (!is_user_logged_in()) {
add_action('init', 'yourtheme_ajax_login_init');
}
if (!function_exists('ajax_login')) {
function ajax_login(){
// First check the nonce, if it fails the function will break
check_ajax_referer( 'ajax-login-nonce', 'security' );
// Nonce is checked, get the POST data and sign user on
$info = array();
$info['user_login'] = $_POST['username'];
$info['user_password'] = $_POST['password'];
$info['remember'] = true;
$user_signon = wp_signon( $info, false );
if ( is_wp_error($user_signon) ){
echo json_encode(array('loggedin'=>false, 'message'=> esc_html__('Wrong username or password.', 'yourtheme')));
} else {
echo json_encode(array('loggedin'=>true, 'message'=> esc_html__('Login successful, redirecting...', 'yourtheme')));
}
die();
}
}
/********* AJAX Registration ***********/
add_action( 'wp_ajax_register_action', 'yourtheme_handle_registration' );
add_action( 'wp_ajax_nopriv_register_action', 'yourtheme_handle_registration' );
if (!function_exists('yourtheme_handle_registration')) {
function yourtheme_handle_registration(){
if( $_POST['action'] == 'register_action' ) {
$error = '';
$uname = trim( $_POST['username'] );
$email = trim( $_POST['mail_id'] );
$fname = trim( $_POST['firname'] );
$lname = trim( $_POST['lasname'] );
if( empty( $_POST['username'] ) )
$error .= '<p class="error">'.esc_html__('Enter username', 'yourtheme').'</p>';
if( empty( $_POST['mail_id'] ) )
$error .= '<p class="error">'.esc_html_('Enter email', 'yourtheme').'</p>';
elseif( !filter_var($email, FILTER_VALIDATE_EMAIL) )
$error .= '<p class="error">'.esc_html__('Enter valid email', 'yourtheme').'</p>';
if( empty( $_POST['firname'] ) )
$error .= '<p class="error">'.esc_html__('Enter first name', 'yourtheme').'</p>';
elseif( !preg_match("/^[a-zA-Z'-]+$/",$fname) )
$error .= '<p class="error">'.esc_html__('Enter valid first name', 'yourtheme').'</p>';
if( empty( $_POST['lasname'] ) )
$error .= '<p class="error">'.esc_html__('Enter last name', 'yourtheme').'</p>';
elseif( !preg_match("/^[a-zA-Z'-]+$/",$lname) )
$error .= '<p class="error">'.esc_html__('Enter valid last name', 'yourtheme').'</p>';
if( empty( $error ) ){
$status = wp_create_user( $uname, $email );
if( is_wp_error($status) ){
$msg = '';
foreach( $status->errors as $key=>$val ){
foreach( $val as $k=>$v ){
$msg = '<p class="error">'.$v.'</p>';
}
}
echo $msg;
} else{
$msg = '<p class="success">'.esc_html__('Registration successful!', 'yourtheme').'</p>';
echo $msg;
}
} else{
echo $error;
}
die(1);
}
}
}
add_action( 'user_register', 'yourtheme_register_user_metadata' );
add_action( 'profile_update', 'yourtheme_register_user_metadata' );
if (!function_exists('yourtheme_register_user_metadata')) {
function yourtheme_register_user_metadata( $user_id ){
if( !empty( $_POST['firname'] ) && !empty( $_POST['lasname'] ) && !empty( $_POST['username'] ) && !empty( $_POST['mail_id'] ) ){
update_user_meta( $user_id, 'first_name', trim($_POST['firname']) );
update_user_meta( $user_id, 'last_name', trim($_POST['lasname']) );
update_user_meta( $user_id, 'username', trim($_POST['username']) );
update_user_meta( $user_id, 'mail_id', trim($_POST['mail_id']) );
}
update_user_meta( $user_id, 'show_admin_bar_front', false );
}
}
ajax-login-script.js
Actual AJAX call and showing and hiding login box on click.
jQuery(document).ready(function($) {
"use strict";
// Show the login dialog box on click
$('a#show_login').on('click', function(e){
$('.ajax_login_overlay').fadeIn(500);
$('form#login').fadeIn(500);
e.preventDefault();
});
$('.ajax_login_overlay').on('click', function(e){
$('form#login').fadeOut(500);
$('.ajax_login_overlay').fadeOut(500);
$('form#register_form').hide();
$('.ajax_login .status').html('');
$('#registration-error-message').html('');
$('form#login').hide();
$('form#register_form .field input').val('');
});
// Perform AJAX login on form submit
$('form#login').on('submit', function(e){
$('form#login p.status').show().text(ajax_login_object.loadingmessage);
$.ajax({
type: 'POST',
dataType: 'json',
url: ajax_login_object.ajaxurl,
data: {
'action': 'ajaxlogin', //calls wp_ajax_nopriv_ajaxlogin
'username': $('form#login #username').val(),
'password': $('form#login #password').val(),
'security': $('form#login #security').val() },
success: function(data){
$('form#login p.status').text(data.message);
if (data.loggedin === true){
document.location.href = ajax_login_object.redirecturl;
}
}
});
e.preventDefault();
});
//Register
$('a#show_register').on('click', function(e){
$('.ajax_login_overlay').fadeIn(500);
$('form#register_form').fadeIn(500);
e.preventDefault();
});
$(document).on('click', '#register-me', function(){
var action = 'register_action';
var username = $("#yourtheme_register-username").val();
var mail_id = $("#yourtheme_register-email").val();
var firname = $("#yourtheme_register-fname").val();
var lasname = $("#yourtheme_register-lname").val();
var ajaxdata = {
action: 'register_action',
username: username,
mail_id: mail_id,
firname: firname,
lasname: lasname,
};
$.post( ajax_login_object.ajaxurl, ajaxdata, function(res){
$("#registration-error-message").html(res);
});
});
});
Now, I tested this, and it works, but it needs some more tests/validation checks and especially security when you are creating a user and logging in (sanitization etc.). It's not 100% my code, I found bunch of it on line, and mashed it up into one. Still needs refinement imo.
Hope this helps, I plan on writing a complete tutorial regarding this once I find the time :)

Firefox columns in css3

Here is the link to my site that I'm building:
http://joshrcook.com/test
I'm having trouble getting the pictures to touch top and bottom without messing up firefox's columns. I can float the images left, but that seems to break -moz-column-count. Any ideas?
Here is the html for the pictures:
<div id="img-wrapper">
<?php for($i = 1; $i <=25; $i++) { ?>
<div class="photo">
<img src="img/arrow_up_alt1_32x32.png" class="overlay overlay1" />
<img src="img/fullscreen_32x32.png" class="overlay overlay2" />
<img src="img/heart_fill_32x38.png" class="overlay overlay3" />
<?php echo '<img src="img/tumblr_img_' . $i . '.jpg" class="main_photo" />'; ?>
</div>
<?php } ?>
</div>
And here is the CSS:
#img-wrapper {
width: 960px;
-moz-column-count: 3;
-webkit-column-count: 3;
column-count: 3;
}
.photo {
width: auto;
position: relative;
width: 320px;
}
.photo a img.overlay {
position: absolute;
z-index: 10;
top: 0;
left: 0;
}
.photo a img.overlay1 {
left: 25%;
}
.photo a img.overlay2 {
left: 45%;
}
.photo a img.overlay3 {
left: 65%;
}
.photo img.main_photo {
width: 320px;
border-radius: 10px;
}
.photo {
width: auto;
position: relative;
width: 320px;
margin-bottom: -5pt;
}
The above seems to work great in Chrome (release) and IE9. I don't have other browsers to test with on this machine, but I'd start there.
Also possibly it could be because of how the browsers are interpreting your whitespace (margins/padding all look like they're set at 0, so the problem shouldn't be there. Try eliminating whitespace within every <div class="photo"></div> and see what that does.

Resources