| 1 |
<?php |
| 2 |
require_once (dirname(__FILE__) . '/adwidgets.php'); |
| 3 |
require_once (dirname(__FILE__) . '/inpostads.php'); |
| 4 |
// action function for above hook |
| 5 |
function smart_add_menu() { |
| 6 |
add_menu_page('Wp-Insert', 'Wp-Insert', 8, __FILE__); |
| 7 |
add_submenu_page(__FILE__, 'wp-insert', 'Manage Ads<br/>(Posts and Sidebars)', 8, __FILE__, 'wp_insert_add_adspage'); |
| 8 |
add_submenu_page(__FILE__, 'wp-insert', 'Manage Ads<br/>(Template Tags)', 8, 'Manage Ads Advanced', 'wp_insert_add_advanced_spage'); |
| 9 |
add_submenu_page(__FILE__, 'wp-insert', 'Manage Feeds', 8, 'Manage Feeds', 'smart_add_feedspage'); |
| 10 |
add_submenu_page(__FILE__, 'wp-insert', 'Tracking Codes', 8, 'Tracking Codes', 'smart_add_analytics'); |
| 11 |
add_submenu_page(__FILE__, 'wp-insert', 'WYSIWYG Editor', 8, 'WYSIWYG Editor', 'smart_add_wysiwyg_pages'); |
| 12 |
add_submenu_page(__FILE__, 'wp-insert', 'Syntax Highlighting', 8, 'Syntax Highlighting', 'smart_add_syntaxhighlighting_pages'); |
| 13 |
//add_submenu_page(__FILE__, 'wp-insert', 'Tracking Codes', 8, 'Manage Feeds', 'wp_insert_add_trackingpage'); |
| 14 |
//ensure, that the needed javascripts been loaded to allow drag/drop, expand/collapse and hide/show of boxes |
| 15 |
wp_enqueue_script('common'); |
| 16 |
wp_enqueue_script('wp-lists'); |
| 17 |
wp_enqueue_script('postbox'); |
| 18 |
//$columns[$screen] = 2; |
| 19 |
} |
| 20 |
|
| 21 |
function wp_insert_add_adspage() { |
| 22 |
global $screen_layout_columns; |
| 23 |
|
| 24 |
add_meta_box('wp_insert_ad_widget_1', 'Ad Widget : 1', 'wp_insert_ad_widget_1_HTML', 'col_2'); |
| 25 |
add_meta_box('wp_insert_ad_widget_2', 'Ad Widget : 2', 'wp_insert_ad_widget_2_HTML', 'col_2'); |
| 26 |
add_meta_box('wp_insert_ad_widget_3', 'Ad Widget : 3', 'wp_insert_ad_widget_3_HTML', 'col_2'); |
| 27 |
add_meta_box('wp_insert_ad_widget_4', 'Ad Widget : 4', 'wp_insert_ad_widget_4_HTML', 'col_2'); |
| 28 |
add_meta_box('wp_insert_ad_widget_5', 'Ad Widget : 5', 'wp_insert_ad_widget_5_HTML', 'col_2'); |
| 29 |
add_meta_box('wp_insert_ad_widget_6', 'Ad Widget : 6', 'wp_insert_ad_widget_6_HTML', 'col_2'); |
| 30 |
add_meta_box('wp_insert_ad_widget_7', 'Ad Widget : 7', 'wp_insert_ad_widget_7_HTML', 'col_2'); |
| 31 |
add_meta_box('wp_insert_ad_widget_8', 'Ad Widget : 8', 'wp_insert_ad_widget_8_HTML', 'col_2'); |
| 32 |
add_meta_box('wp_insert_ad_widget_9', 'Ad Widget : 9', 'wp_insert_ad_widget_9_HTML', 'col_2'); |
| 33 |
add_meta_box('wp_insert_ad_widget_10', 'Ad Widget : 10', 'wp_insert_ad_widget_10_HTML', 'col_2'); |
| 34 |
|
| 35 |
add_meta_box('wp_insert_multiple_ad_network', 'Multiple Ad Networks', 'wp_insert_multiple_ad_network_HTML', 'col_1'); |
| 36 |
add_meta_box('wp_insert_in_post_ad_top_1', 'Ad - Above Post Content', 'wp_insert_in_post_ad_top_1_HTML', 'col_1'); |
| 37 |
add_meta_box('wp_insert_in_post_ad_bottom_1', 'Ad - Below Post Content', 'wp_insert_in_post_ad_bottom_1_HTML', 'col_1'); |
| 38 |
add_meta_box('wp_insert_in_post_ad_left_1', 'Ad - Left of Post Content', 'wp_insert_in_post_ad_left_1_HTML', 'col_1'); |
| 39 |
add_meta_box('wp_insert_in_post_ad_right_1', 'Ad - Right of Post Content', 'wp_insert_in_post_ad_right_1_HTML', 'col_1'); |
| 40 |
add_meta_box('wp_insert_in_post_ad_middle_1', 'Ad - Middle of Post Content', 'wp_insert_in_post_ad_middle_1_HTML', 'col_1'); |
| 41 |
|
| 42 |
$parameters = 'wp_insert_multiple_ad_network_type,'.wp_insert_in_post_ad_parameters('middle_1').','.wp_insert_in_post_ad_parameters('right_1').','.wp_insert_in_post_ad_parameters('left_1').','.wp_insert_in_post_ad_parameters('bottom_1').','.wp_insert_in_post_ad_parameters('top_1').','.wp_insert_ad_widget_parameters(1).','.wp_insert_ad_widget_parameters(2).','.wp_insert_ad_widget_parameters(3).','.wp_insert_ad_widget_parameters(4).','.wp_insert_ad_widget_parameters(5).','.wp_insert_ad_widget_parameters(6).','.wp_insert_ad_widget_parameters(7).','.wp_insert_ad_widget_parameters(8).','.wp_insert_ad_widget_parameters(9).','.wp_insert_ad_widget_parameters(10); |
| 43 |
wp_insert_settings_page_layout($parameters); |
| 44 |
} |
| 45 |
|
| 46 |
function wp_insert_settings_page_layout($page_parameters) { ?> |
| 47 |
<div id="post_ads_container" class="wrap"> |
| 48 |
<?php screen_icon('options-general'); ?> |
| 49 |
<h2>WP-INSERT : Manage Ads (Posts and Sidebars)</h2> |
| 50 |
<div class="updated fade below-h2" id="message" style="opacity:0;display:none;"><p>Changes have been made to this page. Please click <b>Save Changes</b> to make them permanent</p></div> |
| 51 |
<?php show_support_options(); ?> |
| 52 |
<form method="post" action="options.php"> |
| 53 |
<?php |
| 54 |
wp_nonce_field('update-options'); |
| 55 |
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); |
| 56 |
wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); |
| 57 |
?> |
| 58 |
<script type="text/javascript" src="<?php echo WP_PLUGIN_URL; ?>/wp-insert/js/jquery/ui.core.js"></script> |
| 59 |
<script type="text/javascript" src="<?php echo WP_PLUGIN_URL; ?>/wp-insert/js/jquery/ui.draggable.js"></script> |
| 60 |
<script type="text/javascript" src="<?php echo WP_PLUGIN_URL; ?>/wp-insert/js/jquery/jquery.corner.js"></script> |
| 61 |
<?php require_once (dirname(__FILE__) . '/postpicker.php'); ?> |
| 62 |
|
| 63 |
<script type="text/javascript" src="<?php echo WP_PLUGIN_URL; ?>/wp-insert/js/common.js"></script> |
| 64 |
<div id="poststuff" class="metabox-holder has-right-sidebar"> |
| 65 |
<div id="side-info-column" class="inner-sidebar"> |
| 66 |
<?php do_meta_boxes('col_2','advanced',null); ?> |
| 67 |
</div> |
| 68 |
<div id="post-body" class="has-sidebar"> |
| 69 |
<div id="post-body-content" class="has-sidebar-content"> |
| 70 |
<?php do_meta_boxes('col_1','advanced',null); ?> |
| 71 |
<input type="hidden" name="action" value="update" /> |
| 72 |
<input type="hidden" name="page_options" value="<?php echo $page_parameters; ?>" /> |
| 73 |
<p class="submit"> |
| 74 |
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" /> |
| 75 |
</p> |
| 76 |
<p> |
| 77 |
<script type="text/javascript" src="http://www.wp-insert.smartlogix.co.in/wp-content/plugins/wp-adnetwork/wp-adnetwork.php?showad=1"></script> |
| 78 |
</p> |
| 79 |
</div> |
| 80 |
</div> |
| 81 |
<br class="clear"/> |
| 82 |
</div> |
| 83 |
</form> |
| 84 |
</div> |
| 85 |
<script type="text/javascript"> |
| 86 |
//<![CDATA[ |
| 87 |
jQuery(document).ready( function($) { |
| 88 |
// close postboxes that should be closed |
| 89 |
jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed'); |
| 90 |
jQuery('.postbox').addClass('closed'); |
| 91 |
// postboxes setup |
| 92 |
postboxes.add_postbox_toggles('wp-insert'); |
| 93 |
}); |
| 94 |
//]]> |
| 95 |
</script> |
| 96 |
</div> |
| 97 |
<?php } |
| 98 |
|
| 99 |
function wp_insert_in_post_ad_parameters($in_post_adID) { return wp_insert_ad_parameters($in_post_adID, 'in_post_ad'); } |
| 100 |
function wp_insert_in_post_ad_top_1_HTML() { wp_insert_ad_HTML('top_1', 'in_post_ad'); } |
| 101 |
function wp_insert_in_post_ad_bottom_1_HTML() { wp_insert_ad_HTML('bottom_1', 'in_post_ad'); } |
| 102 |
function wp_insert_in_post_ad_left_1_HTML() { wp_insert_ad_HTML('left_1', 'in_post_ad'); } |
| 103 |
function wp_insert_in_post_ad_right_1_HTML() { wp_insert_ad_HTML('right_1', 'in_post_ad'); } |
| 104 |
function wp_insert_in_post_ad_middle_1_HTML() { wp_insert_ad_HTML('middle_1', 'in_post_ad'); } |
| 105 |
|
| 106 |
function wp_insert_ad_widget_parameters($widgetID) { return wp_insert_ad_parameters($widgetID, 'ad_widget'); } |
| 107 |
function wp_insert_ad_widget_1_HTML() { wp_insert_ad_HTML(1, 'ad_widget'); } |
| 108 |
function wp_insert_ad_widget_2_HTML() { wp_insert_ad_HTML(2, 'ad_widget'); } |
| 109 |
function wp_insert_ad_widget_3_HTML() { wp_insert_ad_HTML(3, 'ad_widget'); } |
| 110 |
function wp_insert_ad_widget_4_HTML() { wp_insert_ad_HTML(4, 'ad_widget'); } |
| 111 |
function wp_insert_ad_widget_5_HTML() { wp_insert_ad_HTML(5, 'ad_widget'); } |
| 112 |
function wp_insert_ad_widget_6_HTML() { wp_insert_ad_HTML(6, 'ad_widget'); } |
| 113 |
function wp_insert_ad_widget_7_HTML() { wp_insert_ad_HTML(7, 'ad_widget'); } |
| 114 |
function wp_insert_ad_widget_8_HTML() { wp_insert_ad_HTML(8, 'ad_widget'); } |
| 115 |
function wp_insert_ad_widget_9_HTML() { wp_insert_ad_HTML(9, 'ad_widget'); } |
| 116 |
function wp_insert_ad_widget_10_HTML() { wp_insert_ad_HTML(10, 'ad_widget'); } |
| 117 |
|
| 118 |
function wp_insert_multiple_ad_network_HTML() { |
| 119 |
if(!get_option('wp_insert_multiple_ad_network_type')) { add_option("wp_insert_multiple_ad_network_type", 'Primary Ad Network Only', '', 'yes'); } |
| 120 |
?> |
| 121 |
<div> |
| 122 |
Select the Multiple Ad Network Setup that best suits you : <select name="wp_insert_multiple_ad_network_type" id="wp_insert_multiple_ad_network_type"> |
| 123 |
<?php |
| 124 |
$multiple_ad_network_types = array("Primary Ad Network Only","Primary and Alternate Ad Network 1","All Ad Networks"); |
| 125 |
$output = ''; |
| 126 |
foreach ($multiple_ad_network_types as $multiple_ad_network_type) { |
| 127 |
$output .= '<option'; |
| 128 |
if ( get_option('wp_insert_multiple_ad_network_type') == $multiple_ad_network_type) { $output .= ' selected="selected"'; } |
| 129 |
$output .= '>'.$multiple_ad_network_type.'</option>'; |
| 130 |
} |
| 131 |
echo $output; |
| 132 |
?> |
| 133 |
</select> |
| 134 |
<p> |
| 135 |
<small>Multiple Ad Networks can be setup to display ads from different networks without infringing the terms of any network.<br/>At a time only ads from one network (Randomly Choosen) will be shown.<br/>This feature can also be used to randomly display different sized Ads from the same network.<br/>Please note that this option is global and applied to Template Ads, In Post Ads as well as Ad Widgets.</small> |
| 136 |
</p> |
| 137 |
</div> |
| 138 |
<?php } |
| 139 |
|
| 140 |
function wp_insert_ad_parameters($adID, $ad_type) { |
| 141 |
$output = ''; |
| 142 |
if($ad_type == 'ad_widget') { $output .= 'wp_insert_'.$ad_type.'_'.$adID.'_title,'; } |
| 143 |
$output .= 'wp_insert_'.$ad_type.'_'.$adID.'_enable,wp_insert_'.$ad_type.'_'.$adID.'_content,wp_insert_'.$ad_type.'_'.$adID.'_content_1,wp_insert_'.$ad_type.'_'.$adID.'_content_2,wp_insert_'.$ad_type.'_'.$adID.'_exclude_ids,wp_insert_'.$ad_type.'_'.$adID.'_exclude_home,wp_insert_'.$ad_type.'_'.$adID.'_exclude_archives,wp_insert_'.$ad_type.'_'.$adID.'_style'; |
| 144 |
return $output; |
| 145 |
} |
| 146 |
|
| 147 |
function wp_insert_ad_HTML($adID, $ad_type) { ?> |
| 148 |
<div> |
| 149 |
<?php if(get_option('wp_insert_'.$ad_type.'_'.$adID.'_enable')) { ?><input type="button" id="wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_enable_button" value="Click to Deactivate" class="button" style="font-weight:bold;color:red;" onclick="wpInsertToggleAdWidget('#wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_enable_button', '#wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_enable')"/> |
| 150 |
<?php } else { ?><input type="button" id="wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_enable_button" value="Click to Activate" class="button" style="font-weight:bold;color:#2f9303;" onclick="wpInsertToggleAdWidget('#wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_enable_button', '#wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_enable')"/><?php } ?> |
| 151 |
<input style="display:none;" id="wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_enable" name="wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_enable" type="checkbox" value="1"<?php if(get_option('wp_insert_'.$ad_type.'_'.$adID.'_enable')) echo ' checked="checked"'; ?> /> |
| 152 |
|
| 153 |
<?php if($ad_type == 'template_ad') { ?> |
| 154 |
<p> |
| 155 |
<label for="wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_insertion_code">Code to add in your theme:</label> |
| 156 |
<input id="wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_insertion_code" name="wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_insertion_code" type="text" style="border: medium none ; padding: 3px; font-size: 11px; width: 100%; display: inline;" class="widefat" readonly="true" value="<?php if(function_exists('wp_template_ad')) { wp_template_ad('<?php echo $adID; ?>'); } ?>"/> |
| 157 |
</p> |
| 158 |
<?php } ?> |
| 159 |
|
| 160 |
<?php if($ad_type == 'ad_widget') { ?> |
| 161 |
<p> |
| 162 |
<label for="wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_title">Title:</label> |
| 163 |
<input id="wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_title" class="widefat" type="text" value="<?php echo get_option('wp_insert_'.$ad_type.'_'.$adID.'_title'); ?>" name="wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_title"/> |
| 164 |
</p> |
| 165 |
<?php } ?> |
| 166 |
|
| 167 |
<div style="margin:10px 6px;"> |
| 168 |
<?php if((get_option('wp_insert_multiple_ad_network_type') == "Primary and Alternate Ad Network 1") || (get_option('wp_insert_multiple_ad_network_type') == "All Ad Networks")) { ?><input type="button" id="wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_content_button" value="Primary Ad Code" class="button" style="color:#2f9303;" onclick="SwitchAds('wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_content','wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_content_1','wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_content_2')"/> <?php } else {?><label for="wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_content">Primary Ad Code:</label><?php } ?> |
| 169 |
<?php if((get_option('wp_insert_multiple_ad_network_type') == "Primary and Alternate Ad Network 1") || (get_option('wp_insert_multiple_ad_network_type') == "All Ad Networks")) { ?><input type="button" id="wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_content_1_button" value="Alternative Ad Code : 1" class="button" style="color:red;" onclick="SwitchAds('wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_content_1','wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_content','wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_content_2')"/> <?php } ?> |
| 170 |
<?php if(get_option('wp_insert_multiple_ad_network_type') == "All Ad Networks") { ?><input type="button" id="wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_content_2_button" value="Alternative Ad Code : 2" class="button" style="color:red;" onclick="SwitchAds('wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_content_2','wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_content_1','wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_content')"/> <?php } ?> |
| 171 |
<textarea style="display:block;height:200px;" id="wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_content" class="widefat" name="wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_content" cols="20" rows="16"><?php echo get_option('wp_insert_'.$ad_type.'_'.$adID.'_content'); ?></textarea> |
| 172 |
<textarea style="display:none;height:0px;" id="wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_content_1" class="widefat" name="wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_content_1" cols="20" rows="16"><?php echo get_option('wp_insert_'.$ad_type.'_'.$adID.'_content_1'); ?></textarea> |
| 173 |
<textarea style="display:none;height:0px;" id="wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_content_2" class="widefat" name="wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_content_2" cols="20" rows="16"><?php echo get_option('wp_insert_'.$ad_type.'_'.$adID.'_content_2'); ?></textarea> |
| 174 |
</div> |
| 175 |
|
| 176 |
<div style="margin:6px;"> |
| 177 |
<label for="wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_exclude_ids">Exclude On Posts/Pages:</label><div class="clear"></div> |
| 178 |
<input style="margin: 10px 6px 0pt; float: left; width: 60%;" class="widefat" type="text" value="<?php echo get_option('wp_insert_'.$ad_type.'_'.$adID.'_exclude_ids'); ?>" name="wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_exclude_ids" id="wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_exclude_ids" /> |
| 179 |
<img style="float:left; margin-top:14px; cursor: pointer;" src="<?php echo WP_PLUGIN_URL; ?>/wp-insert/images/search-16x16.png" width="16px" height="16px" onclick="ShowPostPicker('wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_exclude_ids')" /> |
| 180 |
<div class="clear"></div> |
| 181 |
</div> |
| 182 |
<p> |
| 183 |
<label for="wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_exclude_home">Exclude On Home Page:</label> |
| 184 |
<input id="wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_exclude_home" name="wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_exclude_home" type="checkbox" value="1"<?php if(get_option('wp_insert_'.$ad_type.'_'.$adID.'_exclude_home')) echo ' checked="checked"'; ?> /> |
| 185 |
</p> |
| 186 |
<p> |
| 187 |
<label for="wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_exclude_archives">Exclude On Archives Pages:</label> |
| 188 |
<input id="wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_exclude_archives" name="wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_exclude_archives" type="checkbox" value="1"<?php if(get_option('wp_insert_'.$ad_type.'_'.$adID.'_exclude_archives')) echo ' checked="checked"'; ?> /> |
| 189 |
</p> |
| 190 |
|
| 191 |
<div style="margin:6px;padding: 6px;border: 1px solid #DDDDDD;"> |
| 192 |
<label for="wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_style">Ad Box CSS Styler</label><div class="clear"></div> |
| 193 |
<input style="float:left; width:60%; margin: 10px 6px 0pt;background: #FFEEEE;" class="widefat" type="text" value="<?php if(get_option('wp_insert_'.$ad_type.'_'.$adID.'_style') != '') { echo get_option('wp_insert_'.$ad_type.'_'.$adID.'_style'); } else { echo 'margin: 5px;padding: 0px;'; } ?>" name="wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_style" id="wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_style" /> |
| 194 |
<img style="float:left; margin-top:14px; cursor: pointer;" src="<?php echo WP_PLUGIN_URL; ?>/wp-insert/images/style-16x16.png" width="0px" height="0px" onclick="ShowStyler('wp_insert_<?php echo $ad_type; ?>_<?php echo $adID; ?>_style')" /> |
| 195 |
<div class="clear"></div> |
| 196 |
</div> |
| 197 |
|
| 198 |
</div> |
| 199 |
<?php |
| 200 |
} ?> |