Skip to content

Commit

Permalink
Cleaned the code that was messed up after @khaledMohammed000 's commit
Browse files Browse the repository at this point in the history
Cleaned the code that was messed up after @khaledMohammed000 's commit
718fd09
  • Loading branch information
ahmedkaludi committed Dec 15, 2016
1 parent 048edbb commit 065bef9
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 105 deletions.
2 changes: 1 addition & 1 deletion templates/design-manager/design-1/footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<footer class="amp-wp-footer">
<div>
<h2><?php echo esc_html( $this->get( 'blog_name' ) ); ?></h2>
<p>
<p class="copyright_txt">
<?php
global $allowed_html;
echo wp_kses($redux_builder_amp['amp-translator-footer-text'],$allowed_html) ;
Expand Down
154 changes: 60 additions & 94 deletions templates/design-manager/design-1/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,109 +13,75 @@

<body class="<?php echo esc_attr( $this->get( 'body_class' ) ); ?>">

<article class="amp-wp-article ampforwp-custom-index amp-wp-home">

<?php $this->load_parts( array( 'header-bar' ) ); ?>

<article class="amp-wp-article ampforwp-custom-index amp-wp-home">
<?php do_action('ampforwp_post_before_design_elements') ?>

<?php
if ( have_posts() ) :
while ( have_posts() ) : the_post(); ?>
<div class="amp-wp-content amp-wp-article-header amp-loop-list">

<h1 class="amp-wp-title">
<?php $ampforwp_post_url = get_permalink(); ?>
<a href="<?php echo trailingslashit($ampforwp_post_url) . AMP_QUERY_VAR ;?>"><?php the_title() ?></a>
</h1>




<div class="amp-wp-content-loop">
<div class="amp-wp-meta">
<?php $this->load_parts( apply_filters( 'amp_post_template_meta_parts', array( 'meta-author', 'meta-time' ) ) ); ?>
</div>


<?php if ( has_post_thumbnail() ) { ?>
<?php
$thumb_id = get_post_thumbnail_id();
$thumb_url_array = wp_get_attachment_image_src($thumb_id, 'thumbnail', true);
$thumb_url = $thumb_url_array[0];
?>
<div class="home-post-image">
<a href="<?php echo trailingslashit($ampforwp_post_url) . AMP_QUERY_VAR ;?>">
<amp-img src=<?php echo $thumb_url ?> width=100 height=75></amp-img>
</a>
</div>
<?php } ?>
<?php
if(has_excerpt()){
$content = get_the_excerpt();
}else{
$content = get_the_content();
}
?>
<p><?php echo wp_trim_words( $content , '50'); ?></p>

</div>

<?php do_action('ampforwp_post_before_design_elements') ?>

<!--Loop 1-->
<!--Get all the posts here-->
<?php
$args = array( 'post_type' =>'post');
$our_required_post_ids = array();
$query_posts_before = new WP_Query($args);

if ( $query_posts_before->have_posts() ) : while ( $query_posts_before->have_posts() ) : $query_posts_before->the_post(); ?>

<?php array_push($our_required_post_ids,get_the_ID()) ;?>

<?php endwhile; wp_reset_postdata(); ?>
<?php else : ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>

<!--FIltering them here-->
<?php
$i=0;
while($i<10){
$ID = $our_required_post_ids[$i];
$value = get_post_meta($ID);

if($value['ampforwp-amp-on-off'][0] === 'hide-amp'){
unset($our_required_post_ids[$i]);
}
$i++;
}
?>
<!--Filter Posts IDs here Ends-->

<!--loop 2-->
<!--Filter Posts from Query Starts here-->
<?php
$args = array( 'post_type' =>'post');
$query_posts = new WP_Query($args);
if($query_posts->have_posts()) : while($query_posts->have_posts()) : $query_posts->the_post(); ?>

<!--Main Business Logic lies here-->
<?php if(in_array(get_the_ID(),$our_required_post_ids)) { ?>
<div class="amp-wp-content amp-wp-article-header amp-loop-list">

<h1 class="amp-wp-title">
<?php $ampforwp_post_url = get_permalink(); ?>
<a href="<?php echo trailingslashit($ampforwp_post_url) . AMP_QUERY_VAR ;?>"><?php the_title() ?></a>
</h1>

<div class="amp-wp-content-loop">
<div class="amp-wp-meta">
<?php $this->load_parts( apply_filters( 'amp_post_template_meta_parts', array( 'meta-author', 'meta-time' ) ) ); ?>
</div>

<?php if ( has_post_thumbnail() ) { ?>
<?php
$thumb_id = get_post_thumbnail_id();
$thumb_url_array = wp_get_attachment_image_src($thumb_id, 'thumbnail', true);
$thumb_url = $thumb_url_array[0];
?>
<div class="home-post-image">
<a href="<?php echo trailingslashit($ampforwp_post_url) . AMP_QUERY_VAR ;?>">
<amp-img src=<?php echo $thumb_url ?> width=100 height=75></amp-img>
</a>
</div>
<?php } ?>

<?php
if(has_excerpt()){
$content = get_the_excerpt();
}else{
$content = get_the_content();
}
?>

<p><?php echo wp_trim_words( $content , '50'); ?></p>
</div>
</div>
<?php } ?>
<!--Main Business Logic Ends here-->
<?php endwhile; wp_reset_postdata(); ?>
<!--Filter Posts from Query Starts here-->

<!--Finally adding pagination links here-->
<div class="amp-wp-content pagination-holder">
<div id="pagination">
<div class="next"><?php next_posts_link( $redux_builder_amp['amp-translator-next-text']. ' &raquo;', 0 ) ?></div>
<div class="prev"><?php previous_posts_link( '&laquo; '. $redux_builder_amp['amp-translator-previous-text'] ); ?></div>
<div class="clearfix"></div>
</div>
</div>
<!--Finally adding pagination links Ends here-->
<?php endif; ?>
<!--loop 2 Ends here-->
<?php endwhile; ?>

<div class="amp-wp-content pagination-holder">

<div id="pagination">
<div class="next"><?php next_posts_link( $redux_builder_amp['amp-translator-next-text']. ' &raquo;', 0 ) ?></div>
<div class="prev"><?php previous_posts_link( '&laquo; '. $redux_builder_amp['amp-translator-previous-text'] ); ?></div>
<div class="clearfix"></div>
</div>

</div>

<?php endif; ?>

<?php do_action('ampforwp_post_after_design_elements') ?>

</article>



<?php $this->load_parts( array( 'footer' ) ); ?>

<?php do_action( 'amp_post_template_footer', $this ); ?>
Expand Down
14 changes: 4 additions & 10 deletions templates/design-manager/design-1/style.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ function ampforwp_additional_style_input( $amp_template ) {
.amp-wp-footer {
border-top: 1px solid <?php echo sanitize_hex_color( $border_color ); ?>;
margin: calc(1.5em - 1px) 0 0;
padding-bottom:25px;
}

.amp-wp-footer div {
Expand All @@ -377,21 +378,14 @@ function ampforwp_additional_style_input( $amp_template ) {
color: <?php echo sanitize_hex_color( $muted_text_color ); ?>;
font-size: .8em;
line-height: 1.5em;
margin: 0 85px 0 0;
margin: 0 15px 0 0;
}

.amp-wp-footer a {
text-decoration: none;
}

.back-to-top {
bottom: 1.275em;
font-size: .8em;
font-weight: 600;
line-height: 2em;
position: absolute;
right: 16px;
}
.copyright_txt{ float:left }
.back-to-top { float:right }


/* Header */
Expand Down

0 comments on commit 065bef9

Please sign in to comment.