$o_value) {
$output[$o_key] = trim($o_value);
}
return $output;
}
/**
* Get plugin options
*/
function an_get_option($option_key) {
$options = get_option('an_options');
if(is_array($options) && array_key_exists($option_key, $options)) {
return $options[$option_key];
} else {
return false;
}
}
/**
* Ads...
*/
function an_ads_disable() {
$an_options = get_option('an_options');
//No settings present, or not the one we are looking for
if(! is_array($an_options) || ! array_key_exists('an_ads_disable', $an_options)) {
global $wpdb;
//Check post meta
$results = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "postmeta` WHERE `meta_key` LIKE '%ad_SellerID%'", ARRAY_A);
//If post meta
if(sizeof($results) > 0) {
//Don't disable
$an_options['an_ads_disable'] = false;
//If no page meta
} else {
//Then check for widget meta WITH DATA
$results = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "options` WHERE option_name LIKE 'widget_an_%_widget' AND option_value LIKE '%siteid%'", ARRAY_A);
//If widget meta
if(sizeof($results) > 0) {
//Don't disable
$an_options['an_ads_disable'] = false;
//No widget meta either
} else {
//Disable
$an_options['an_ads_disable'] = true;
}
}
update_option('an_options', $an_options);
}
}
add_action('admin_init', 'an_ads_disable');
/**
* Username change
*/
function an_propagate_username_change($an_new_username) {
global $wpdb;
//Update posts...
$wpdb->query(
$wpdb->prepare("
UPDATE $wpdb->postmeta
SET meta_value = '%s'
WHERE meta_key IN('item_SellerID', 'ad_SellerID', 'profile_UserID', 'feedback_UserID')
", $an_new_username)
);
//Update widgets...
//Ad widgets
$an_widgets_options = get_option('widget_an_ads_widget');
foreach($an_widgets_options as &$an_widget_options) {
if(is_array($an_widget_options) && array_key_exists('ad_SellerID', $an_widget_options)) {
$an_widget_options['ad_SellerID'] = $an_new_username;
}
}
update_option('widget_an_ads_widget', $an_widgets_options);
//Feedback widgets
$an_widgets_options = get_option('widget_an_feedback_widget');
foreach($an_widgets_options as &$an_widget_options) {
if(is_array($an_widget_options) && array_key_exists('feedback_UserID', $an_widget_options)) {
$an_widget_options['feedback_UserID'] = $an_new_username;
}
}
update_option('widget_an_feedback_widget', $an_widgets_options);
//Profile widgets
$an_widgets_options = get_option('widget_an_profile_widget');
foreach($an_widgets_options as &$an_widget_options) {
if(is_array($an_widget_options) && array_key_exists('profile_UserID', $an_widget_options)) {
$an_widget_options['profile_UserID'] = $an_new_username;
}
}
update_option('widget_an_profile_widget', $an_widgets_options);
//Listings widget
$an_widgets_options = get_option('widget_an_listings_widget');
foreach($an_widgets_options as &$an_widget_options) {
if(is_array($an_widget_options) && array_key_exists('item_SellerID', $an_widget_options)) {
$an_widget_options['item_SellerID'] = $an_new_username;
}
}
update_option('widget_an_listings_widget', $an_widgets_options);
}
/**
* Helpful upgrade notification
*/
function an_show_upgrade_notification($current_plugin_metadata, $new_plugin_metadata){
//Check Upgrade Notice
if(isset($new_plugin_metadata->upgrade_notice) && strlen(trim($new_plugin_metadata->upgrade_notice)) > 0) {
echo '
Important Update!
' . strip_tags($new_plugin_metadata->upgrade_notice);
}
}
add_action('in_plugin_update_message-auction-nudge/auctionnudge.php', 'an_show_upgrade_notification', 10, 2);
/**
* Modify plugin action links
*/
function an_add_action_links($links) {
$links_before = array();
$links_after = array(
'Settings',
);
return array_merge($links_before, $links, $links_after);
}
add_filter('plugin_action_links_auction-nudge/auctionnudge.php', 'an_add_action_links');
/**
* ================= CUSTOM FIELDS ========================
*/
/**
* Create the custom fields box
*/
function an_create_custom_fields_box() {
foreach(array('post', 'page') as $post_type) {
add_meta_box('an-custom-fields', an_get_config('plugin_name'), 'an_create_custom_field_form', $post_type, 'normal', 'high');
}
}
/**
* Create the custom field form
*/
function an_create_custom_field_form() {
global $post;
//Get post meta
$post_meta = get_post_meta($post->ID);
$out = '
Use these options to specify which of your eBay items to display within your page/post.
Add the following shortcode within your content editor to specify where the items will appear:
[' . an_get_config('shortcode') . ' tool="listings"]
Note: Only one set of eBay listings can be loaded per page.
' . "\n"; $out .= ' Help' . "\n"; $out .= '
Auction Nudge Pro is coming!
Find out more »
Auction Nudge Pro is coming! Find out more
' . "\n"; echo '
' . "\n";
echo ' Hi, I\'m Joe and I created this plugin.
' . "\n"; echo 'I highly recommend watching the Walk-through Video on how to use the plugin.
' . "\n"; echo 'Most common issues are solved by reading the Help section. Bugs and errors can be reported here. Please do this before leaving a poor review.
' . "\n"; echo 'If you like the plugin, please show your appreciation by leaving a rating. It really does help.
' . "\n"; echo 'Thanks!
' . "\n"; echo ' Walk-through Video' . "\n"; echo ' Plugin Help' . "\n"; echo ' Rate the plugin ' . "\n"; echo 'To add Auction Nudge to your pages or posts, use the Auction Nudge box on the edit page. You can also add Auction Nudge to your theme as Widgets. The Settings below can be used to specify some defaults and style rules, but are not required.
' . "\n"; echo 'For more details on how to use the plugin, you can watch the Walk-through Video.
' . "\n"; //Tabs $active_tab = (isset($_GET['tab'])) ? $_GET['tab'] : 'general'; an_admin_tabs($active_tab); //Open form echo ' ' . "\n"; echo 'Entering a default eBay username and site here will save you from re-entering them on each page, post or widget where you want to use Auction Nudge.
' . "\n"; } /** * Output eBay ID option */ function an_ebay_user_setting() { $options = get_option('an_options'); //Option set? if(is_array($options) && array_key_exists('an_ebay_user', $options)) { $ebay_user_setting = $options['an_ebay_user']; } else { $ebay_user_setting = ''; } echo '' . "\n"; echo '?' . "\n"; echo 'You can modify the appearance of Auction Nudge by pasting CSS rules into this box.
' . "\n"; echo 'For example div#auction-nudge-items a { color: red } will make all links displayed by the Your eBay Listings tool red. You can find more information and demos on modifying the appearance of Auction Nudge here.
The plugin utilises the in-built WordPress caching mechanism to deliver Auction Nudge content, increasing performance.
' . "\n"; echo 'If you are experiencing issues with Auction Nudge (like if nothing is displayed), try changing this setting to "No". Don\'t worry, other caching mechanisms are still in place.
' . "\n"; } /** * Local Requests option */ function an_local_requests_setting() { $options = get_option('an_options'); $an_local_requests = isset($options['an_local_requests']) ? $options['an_local_requests'] : '1'; echo '' . "\n"; } /** * ==================== LEGACY ============================ */ /** * Items text */ function an_items_text() { echo 'To begin you must obtain your code snippet from the Auction Nudge website here (shown as "Copy the code snippet onto your site") and paste it into the box below.
' . "\n"; echo 'You can then call <?php an_items(); ?> from within your theme files to display Your eBay Listings where desired.
To begin you must obtain your code snippet from the Auction Nudge website here (shown as "Copy the code snippet onto your site") and paste it into the box below.
' . "\n"; echo 'You can then call <?php an_profile(); ?> from within your theme files to display Your eBay Profile where desired.
To begin you must obtain your code snippet from the Auction Nudge website here (shown as "Copy the code snippet onto your site") and paste it into the box below.
' . "\n"; echo 'You can then call <?php an_feedback(); ?> from within your theme files to display Your eBay Feedback where desired.