Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored into more standard plugin structure with views, classes, separate functions file #2

Merged
merged 5 commits into from Jun 21, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -0,0 +1,81 @@
<?php
/**
* Plugin Name: Amazin' Product Box
* Plugin URI: http://majoh.dev
* Description: Customizable product box for Amazon products with an affiliate link
* Version: 1.0
* Author: Mandi Grant
* Author URI: http://majoh.dev
*/
add_action( 'init', function() {
include dirname( __FILE__ ) . '/includes/class-amazin-product-box-admin-menu.php';
include dirname( __FILE__ ) . '/includes/class-amazin-product-box-list-table.php';
include dirname( __FILE__ ) . '/includes/class-form-handler.php';
include dirname( __FILE__ ) . '/includes/amazin-product-box-functions.php';
$cssurl = plugin_dir_url(__FILE__) . 'styles.css';
wp_enqueue_style( 'amazin-stylesheet', $cssurl, array(), 1.23 );
register_post_type('amazin_product_box',
array(
'labels' => array(
'name' => __( 'Amazin Product Boxes' ),
'singular_name' => __( ' Amazin Product Box ')
),
'public' => false,
'show_ui' => false,
'query_var' => false,
'rewrite' => false,
'capability_type' => 'amazin_product_box',
'has_archive' => true,
'can_export' => true,
)
);
new Amazin_Product_Box_Admin_Menu();
});
function amazin_product_box_shortcode( $atts ) {
$a = shortcode_atts( array(
'id' => 'id'
), $atts );
$productBox = get_post($a['id']);
if ($productBox) {
return amazin_product_box_render_in_post($productBox);
} else {
return 'Error displaying Amazin Product Box';
}
}
function amazin_product_box_render_in_post($productBox) {
ob_start();
$id = $productBox->ID;
$productBoxTitle = $productBox->post_title;
$stripped = stripslashes($productBox->post_content);
$content = json_decode($stripped, true);
?>
<div class="amazin-product-box" id="<?php echo 'amazin-product-box-id-'.$id; ?>">
<p class="amazin-product-box-recommend-text">We recommend</p>
<h3 class="amazin-product-box-product-name"><?php echo $productBoxTitle ?></h3>
<div class="row">
<div class="amazin-product-box-column amazin-product-box-left">
Picture placeholder
</div>
<div class="amazin-product-box-column amazin-product-box-right">
<p class="amazin-product-box-tagline"><?php echo $content['productTagline'] ?></p>
<p class="amazin-product-box-description" ><?php echo $content['productDescription'] ?></p>
</div>
</div>
<div class="amazin-product-box-button-wrap">
<a href="<?php echo $content['productLink'] ?>" class="amazin-product-box-button"><?php echo $content['productButtonText'] ?></a>
</div>
</div>
<?php
return ob_get_clean();
}
add_shortcode( 'amazin-product-box', 'amazin_product_box_shortcode' );
?>

This file was deleted.

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.