Skip to content

Commit

Permalink
Functionality Updates
Browse files Browse the repository at this point in the history
- Infinite scrolling on archive page using JS & REST API
- Improved archive page SCSS.
- Fixed namespacing for hook names.
- Modify posts_per_page to 6
  • Loading branch information
sfgarza committed Mar 31, 2020
1 parent ab6213e commit 68bc893
Show file tree
Hide file tree
Showing 7 changed files with 273 additions and 1,057 deletions.
2 changes: 1 addition & 1 deletion assets/css/link-in-bio.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/css/link-in-bio.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 66 additions & 2 deletions assets/scss/link-in-bio.scss
Original file line number Diff line number Diff line change
@@ -1,13 +1,77 @@
.bio-circle {
border-radius: 50%;
height: 80;
height: 80px;
width: 80px;
display: block;
margin-left: auto;
margin-right: auto;
}

.libio-header{
text-align: center;
padding-top:20px;
//padding-bottom:20px;
height: 150px;
width: 100%;
position: relative;
overflow: visible;
z-index: 1;
border-bottom: 1px solid #ababab
}

.lib-header {
.libio-page-container{
text-align: center;
padding-top:20px;
padding-bottom:20px;
}

.libio-container {
max-width: 960px;
margin: auto;
display: flex;
flex-direction: row;
flex-wrap: wrap
}

.libio-container .libio-photo-wrapper {
flex: 0 0 auto;
width: 33.3%;
position: relative;
padding: 2px;
box-sizing: border-box
}

.libio-container .libio-photo-wrapper:after {
content: "";
display: block;
padding-bottom: 100%
}

.libio-container .libio-photo-wrapper .libio-photo {
position: relative;
display: block
}

.libio-container .libio-photo-wrapper .libio-photo img {
width: 100%;
height: auto;
display: block;
position: absolute;
vertical-align: baseline;
left: 0;
top: 0;
right: 0;
bottom: 0
}

@media (max-width:960px) {
.libio-container .libio-photo-wrapper {
width: 49.8%
}
.libio-container .libio-photo-wrapper .overlay {
display: none
}
.ls-tip {
background: #f5f5f5
}
}
26 changes: 19 additions & 7 deletions link-in-bio-wp.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

/* Include dependencies */
include_once( 'includes.php' );

/** Instantiate the plugin. */
WP_LinkInBio::get_instance();

Expand Down Expand Up @@ -128,6 +127,8 @@ private function init() {
register_activation_hook( static::$plugin_file, array( $this, 'activate' ) );
register_deactivation_hook( static::$plugin_file, array( $this, 'deactivate' ) );

add_image_size( 'image_link', 250, 250, true );

/** Enqueue css and js files */
add_action( 'wp_enqueue_scripts', array( $this, 'frontend_scripts' ) );

Expand All @@ -137,7 +138,7 @@ private function init() {
add_action( 'init', array( $this, 'create_post_type' ) );
add_action( 'init', array( $this, 'register_post_meta' ) );
add_filter( 'template_include', array($this, 'include_template') );

add_filter( 'pre_get_posts', array( $this, 'posts_per_page' ) );
// No need to define metaboxes/save post function unless it's accessible.
if ( is_admin() ) {
//add_filter( 'manage_edit-link-in-bio_columns', array( $this, 'columns_filter' ) );
Expand Down Expand Up @@ -183,7 +184,7 @@ public function create_post_type() {
'public' => true,
'query_var' => true,
'show_in_rest' => true,
'rest_base' => 'pr',
'rest_base' => 'links',
'rest_controller_class' => 'WP_REST_Posts_Controller',
'menu_position' => 5,
'menu_icon' => 'dashicons-admin-links',
Expand Down Expand Up @@ -225,9 +226,9 @@ public function register_meta_boxes() {
public function general_metabox() {
global $post;

wp_nonce_field( 'link_in_bio_metabox_save', 'link_in_bio_metabox_nonce' );
wp_nonce_field( 'linkinbio_metabox_save', 'linkinbio_metabox_nonce' );

echo '<p><label>Redirect Link:</label><br /><input type="text" name="link_in_bio_redirect_link" value="' . esc_attr( get_post_meta( $post->ID, "_linkinbio_redirect_link", true ) ) .'"/></p>';
echo '<p><label>Redirect Link:</label><br /><input type="text" name="linkinbio_redirect_link" value="' . esc_attr( get_post_meta( $post->ID, "_linkinbio_redirect_link", true ) ) .'"/></p>';
}

/**
Expand All @@ -242,7 +243,7 @@ public function general_metabox() {
public function metabox_save( $post_id, $post ) {

// Check nonce.
if ( ! isset( $_POST['link_in_bio_metabox_nonce'] ) || ! wp_verify_nonce( $_POST['link_in_bio_metabox_nonce'], 'link_in_bio_metabox_save' ) ) {
if ( ! isset( $_POST['linkinbio_metabox_nonce'] ) || ! wp_verify_nonce( $_POST['linkinbio_metabox_nonce'], 'linkinbio_metabox_save' ) ) {
return $post_id;
}

Expand All @@ -262,7 +263,7 @@ public function metabox_save( $post_id, $post ) {
}

// Validate and sanitize redirect url.
$redirect_link = wp_http_validate_url( esc_url_raw( trim( $_POST['link_in_bio_redirect_link'] ) ) );
$redirect_link = wp_http_validate_url( esc_url_raw( trim( $_POST['linkinbio_redirect_link'] ) ) );
$redirect_link = (false !== $redirect_link ) ? $redirect_link : '';

// Perform save.
Expand Down Expand Up @@ -313,6 +314,7 @@ public function activate() {
* Method that executes on plugin de-activation.
*/
public function deactivate() {
//remove_image_size( 'image_link' );
add_action( 'plugins_loaded', 'flush_rewrite_rules' );
}

Expand All @@ -327,4 +329,14 @@ public function plugin_links( $links ) {
array_unshift( $links, $settings_link );
return $links;
}

function posts_per_page( $query ) {
if ( is_admin() || ! $query->is_main_query() ) {
return;
}

if ( is_post_type_archive( 'link-in-bio' ) ) {
$query->set( 'posts_per_page', 6 );
}
}
}
Loading

0 comments on commit 68bc893

Please sign in to comment.