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

Release candidate 1 #5

Merged
merged 5 commits into from Jun 23, 2019
Merged
@@ -2,7 +2,7 @@
/**
* Plugin Name: Amazin' Product Box
* Plugin URI: http://majoh.dev
* Description: Customizable product box for Amazon products with an affiliate link
* Description: Showcase your recommended products in your posts with eye-catching product boxes
* Version: 1.0
* Author: Mandi Grant
* Author URI: http://majoh.dev
@@ -20,7 +20,7 @@
wp_enqueue_script('admin', $jsurl, array( 'jquery' ), 1.1, true);
$cssurl = plugin_dir_url(__FILE__) . 'styles.css';
wp_enqueue_style( 'amazin-stylesheet', $cssurl, array(), 1.30 );
wp_enqueue_style( 'amazin-stylesheet', $cssurl, array(), 1.32 );
register_post_type('amazin_product_box',
array(
@@ -39,11 +39,21 @@
);
add_option( 'amazin_product_box_option_headline', 'We recommend');
add_option( 'amazin_product_box_option_new_tab', false);
register_setting( 'amazin_product_box_options_group', 'amazin_product_box_option_headline', 'amazin_product_box_callback' );
register_setting( 'amazin_product_box_options_group', 'amazin_product_box_option_new_tab', 'amazin_product_box_callback' );
add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'add_plugin_action_links' );
new Amazin_Product_Box_Admin_Menu();
});
function add_plugin_action_links( $links ) {
$plugin_url = admin_url( 'admin.php?page=amazinProductBox' );
$links[] = '<a href="' . $plugin_url . '">' . __( 'Manage Product Boxes', 'apb' ) . '</a>';
return $links;
}
function amazin_product_box_shortcode( $atts ) {
$a = shortcode_atts( array(
'id' => 'id'
@@ -64,6 +74,8 @@ function amazin_product_box_render_in_post($productBox) {
$productBoxTitle = $productBox->post_title;
$stripped = stripslashes($productBox->post_content);
$content = json_decode($stripped, true);
$newTab = get_option('amazin_product_box_option_new_tab') ? 'target="_blank"' : '';
?>
<div class="amazin-product-box" id="<?php echo 'amazin-product-box-id-'.$id; ?>">
<p class="amazin-product-box-recommend-text"><?php echo get_option('amazin_product_box_option_headline'); ?></p>
@@ -78,7 +90,7 @@ function amazin_product_box_render_in_post($productBox) {
</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>
<a href="<?php echo $content['productUrl'] ?>" class="amazin-product-box-button" <?php echo $newTab ?> ><?php echo $content['productButtonText'] ?></a>
</div>
</div>
<?php
@@ -39,9 +39,11 @@
<div class="upload">
<img data-src="<?php echo $phURL ?>" src="<?php echo $image; ?>" width="120px" height="120px" />
<div>
<input type="hidden" name="Product-Image" id="Product-Image" value="" />
<input type="hidden" name="Product-Image" id="Product-Image" value="<?php echo $content['productImage'] ?>" />
<button type="submit" class="upload_image_button button"><?php _e( 'Upload/Choose', 'apb' ); ?></button>
<button type="submit" class="remove_image_button button"><?php _e( 'Clear', 'apb' ); ?></button>
<br/>
<span class="description"><?php _e('Choose an image that is large (at least 1000x1000 pixels) and square', 'apb' ); ?></span>
</div>
</div>
</td>
@@ -21,20 +21,36 @@
</form>

<form method="post" action="options.php">
<?php settings_fields( 'amazin_product_box_options_group' ); ?>
<?php
$options = settings_fields( 'amazin_product_box_options_group' );
$newTab = get_option('amazin_product_box_option_new_tab') ? 'checked' : ''; //$options['amazin_product_box_new_tab'];
?>
<h3>Product box settings</h3>
<p>These settings are shared by all product boxes on your site.</p>
<table>
<tr valign="top">
<th scope="row">
<label for="amazin_product_box_option_headline">Product Box Headline</label>
</th>
<td>
<input type="text" id="amazin_product_box_option_headline" name="amazin_product_box_option_headline" value="<?php echo get_option('amazin_product_box_option_headline'); ?>" />
<br/>
<span class="description"><?php _e('Examples: "We recommend", "Our pick", "A Sitename Favorite", etc.', 'apb' ); ?></span>
</td>
</tr>
<table class="form-table">
<tbody>
<tr>
<th scope="row">
<label for="amazin_product_box_option_headline">Product Box headline</label>
</th>
<td>
<input type="text" id="amazin_product_box_option_headline" name="amazin_product_box_option_headline" value="<?php echo get_option('amazin_product_box_option_headline'); ?>" />
<br/>
<span class="description"><?php _e('Examples: "We recommend", "Our pick", "A Sitename Favorite", etc.', 'apb' ); ?></span>
</td>
</tr>
<tr>
<th scope="row">
<label for="amazin_product_box_option_new_tab">Open link in new tab</label>
</th>
<td>
<input type="checkbox" id="amazin_product_box_option_new_tab" name="amazin_product_box_option_new_tab" value="newTab" <?php checked( 'newTab', get_option('amazin_product_box_option_new_tab') ); ?> />
<br/>
<span class="description"><?php _e('The button link should open in a new browser tab', 'apb' ); ?></span>
</td>
</tr>
</tbody>
</table>
<?php submit_button(); ?>
</form>
@@ -33,6 +33,8 @@
<input type="hidden" name="Product-Image" id="Product-Image" value="" />
<button type="submit" class="upload_image_button button"><?php _e( 'Upload/Choose', 'apb' ); ?></button>
<button type="submit" class="remove_image_button button"><?php _e( 'Clear', 'apb' ); ?></button>
<br/>
<span class="description"><?php _e('Choose an image that is large (at least 1000x1000 pixels) and square', 'apb' ); ?></span>
</div>
</div>
</td>
@@ -3,8 +3,8 @@
border:1px solid grey;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
padding:28px;
/* width:700px; */ /* uncomment to center in post */
/* margin:0 auto !important;*/ /* uncomment to center in post */
width:80%;
margin:0 auto !important;
}

.amazin-product-box-column {
@@ -4,12 +4,13 @@
die;
}
$option_name = 'amazin_product_box_option_headline';
$option_names = array('amazin_product_box_option_headline', 'amazin_product_box_option_new_tab');
foreach ($option_names as $option_name) {
delete_option($option_name);
delete_option($option_name);
// for site options in Multisite
delete_site_option($option_name);
// for site options in Multisite
delete_site_option($option_name);
}
// drop a custom database table
global $wpdb;
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.