widget javascript
-
<?php
/*
Plugin Name: HTML Javascript Adder
Plugin URI: http://www.aakashweb.com
Description: A widget plugin for adding javascripts, HTML scripts, javascripts, advertisements and even simple texts in the sidebar with advanced targeting on posts and pages.
Author: Aakash Chakravarthy
Version: 3.1.1
Author URI: http://www.aakashweb.com/
*//*
Copyright 2011 Aakash Chakravarthy (email : (email visible only to moderators and staff)) (website : http://www.aakashweb.com)This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA**********************************
In short, this plugin is free to use by anyone and everyone. As this plugin is free,
you can also donate and support this plugin if you like.*********************************/
define(‘HJA_VERSION’, ‘3.1.1’);
define(‘HJA_AUTHOR’, ‘Aakash Chakravarthy’);if (!defined(‘WP_CONTENT_URL’)) {
$hja_pluginpath = get_option(‘siteurl’).’/wp-content/plugins/’.plugin_basename(dirname(__FILE__)).’/’;
} else {
$hja_pluginpath = WP_CONTENT_URL . ‘/plugins/’ . plugin_basename(dirname(__FILE__)) . ‘/’;
}$hja_donate_link = ‘http://bit.ly/hjadonate’;
## Load languages
load_plugin_textdomain(‘hja’, false, basename(dirname(__FILE__)) . ‘/languages/’);class html_javascript_adder_widget extends WP_Widget{
## Initialize
function html_javascript_adder_widget(){
$widget_ops = array(‘classname’ => ‘widget_html_javascript_adder’, ‘description’ => __(“Used to add HTML, javascripts, Flash embed codes to sidebar”, ‘hja’) );
$control_ops = array(‘width’ => 530, ‘height’ => 500);
$this->WP_Widget(‘html_javascript_adder’, __(‘HTML Javascript Adder’, ‘hja’), $widget_ops, $control_ops);
}function hja_page_check($instance){
$hja_is_single = $instance[‘hja_is_single’];
$hja_is_archive = $instance[‘hja_is_archive’];
$hja_is_home = $instance[‘hja_is_home’];
$hja_is_page = $instance[‘hja_is_page’];
$hja_is_search = $instance[‘hja_is_search’];if (is_home() == 1 && $hja_is_home != 1){
return true;}elseif (is_single() == 1 && $hja_is_single!= 1){
return true;}elseif (is_page() == 1 && $hja_is_page != 1){
return true;}elseif (is_archive() == 1 && $hja_is_archive != 1){
return true;}elseif (is_tag() == 1 && $hja_is_archive != 1){
return true;}elseif(is_search() == 1 && $hja_is_search != 1){
return true;}else{
return false;
}
}function hja_admin_check($instance){
$hja_is_admin = $instance[‘hja_is_admin’];if(current_user_can(‘level_10’) && $hja_is_admin == 1){
return false;
}else{
return true;
}
}function hja_post_check($instance){
global $post;
$hja_diable_post = $instance[‘hja_diable_post’];
$splitId = explode(‘,’, $hja_diable_post);if(is_page($splitId) || is_single($splitId)){
return false;
}else{
return true;
}
}function hja_all_ok($instance){
return (
$this->hja_page_check($instance) &&
$this->hja_admin_check($instance) &&
$this->hja_post_check($instance)
);
}## Display the Widget
function widget($args, $instance){
extract($args);
$hja_title = apply_filters(‘widget_title’, empty($instance[‘hja_title’]) ? ” : $instance[‘hja_title’], $instance, $this->id_base);if(empty($instance[‘hja_content’])){
$hja_content = ”;
}elseif($instance[‘hja_add_para’] == 1){
$hja_content = wpautop($instance[‘hja_content’]);
}else{
$hja_content = $instance[‘hja_content’];
}$hja_before_content = “n” . ‘<div class=”hjawidget”>’ . “n”;
$hja_after_content = “n” . ‘</div>’ . “n”;## Output
$hja_output_content =
$before_widget . “nn<!– Start – HTML Javascript Adder plugin v” . HJA_VERSION . ” –>n” .
$before_title .
$hja_title .
$after_title .
$hja_before_content .
$hja_content .
$this->hja_link_back() .
$hja_after_content .
“<!– End – HTML Javascript Adder plugin v” . HJA_VERSION . ” –>nn” .
$after_widget;if($this->hja_all_ok($instance)){
echo $hja_output_content;
}define(‘IS_HJA_ADDED’, 1);
}## Save settings
function update($new_instance, $old_instance){
$instance = $old_instance;
$instance[‘hja_title’] = stripslashes($new_instance[‘hja_title’]);
$instance[‘hja_content’] = stripslashes($new_instance[‘hja_content’]);$instance[‘hja_is_single’] = $new_instance[‘hja_is_single’];
$instance[‘hja_is_archive’] = $new_instance[‘hja_is_archive’];
$instance[‘hja_is_home’] = $new_instance[‘hja_is_home’];
$instance[‘hja_is_page’] = $new_instance[‘hja_is_page’];
$instance[‘hja_is_search’] = $new_instance[‘hja_is_search’];$instance[‘hja_add_para’] = $new_instance[‘hja_add_para’];
$instance[‘hja_is_admin’] = $new_instance[‘hja_is_admin’];
$instance[‘hja_diable_post’] = $new_instance[‘hja_diable_post’];$instance[‘hja_heading_select’] = $new_instance[‘hja_heading_select’];
return $instance;
}## HJA Widget form
function form($instance){
global $hja_donate_link;$instance = wp_parse_args( (array) $instance, array(‘hja_title’=>”, ‘hja_content’=>”,’hja_is_single’=>”,’hja_is_archive’=>”,’hja_is_home’=>”,’hja_is_search’=>” ) );
$hja_title = htmlspecialchars($instance[‘hja_title’]);
$hja_content = htmlspecialchars($instance[‘hja_content’]);$hja_is_single = $instance[‘hja_is_single’];
$hja_is_archive = $instance[‘hja_is_archive’];
$hja_is_home = $instance[‘hja_is_home’];
$hja_is_page = $instance[‘hja_is_page’];
$hja_is_search = $instance[‘hja_is_search’];$hja_add_para = $instance[‘hja_add_para’];
$hja_is_admin = $instance[‘hja_is_admin’];
$hja_diable_post = $instance[‘hja_diable_post’];
?><div class=”section”>
<!– Title text box for admin widget title –>
<input id=”<?php echo $this->get_field_id(‘title’);?>” name=”<?php echo $this->get_field_name(‘title’); ?>” type=”hidden” value=”<?php echo $hja_title; ?>” class=”widefat”><label><?php _e(‘Title :’, ‘hja’); ?>
<input id=”<?php echo $this->get_field_id(‘hja_title’);?>” name=”<?php echo $this->get_field_name(‘hja_title’); ?>” type=”text” value=”<?php echo $hja_title; ?>” class=”widefat”/>
</label>
</div><div class=”section”>
<label for=”<?php echo $this->get_field_id(‘hja_content’); ?>”><?php _e(‘Content :’, ‘hja’); ?></label>
<div class=”awQuickTagToolbar”><select id=”<?php echo $this->get_field_id(‘hja_heading_select’); ?>” onChange=”awQuickTagsHeading(‘<?php echo $this->get_field_id(‘hja_content’); ?>’, ‘<?php echo $this->get_field_id(‘hja_heading_select’); ?>’);”><option value=”1″>Heading 1</option><option value=”2″>Heading 2</option><option value=”3″>Heading 3</option><option value=”4″>Heading 4</option><option value=”5″>Heading 5</option><option value=”6″>Heading 6</option></select><input type=”button” onClick=”awQuickTags(‘<?php echo $this->get_field_id(‘hja_content’); ?>’,’‘,’‘,”);” value=”B”/><input type=”button” onClick=”awQuickTags(‘<?php echo $this->get_field_id(‘hja_content’); ?>’,’‘,’‘,”);” value=”I”/><input type=”button” onClick=”awQuickTags(‘<?php echo $this->get_field_id(‘hja_content’); ?>’,'<u>’,'</u>’,”);” value=”U”/><input type=”button” onClick=”awQuickTags(‘<?php echo $this->get_field_id(‘hja_content’); ?>’,’‘,’a’);” value=”<?php _e(“Link”, ‘hja’); ?>”/><input type=”button” onClick=”awQuickTags(‘<?php echo $this->get_field_id(‘hja_content’); ?>’,'<img ‘,’/>’,’img’);” value=”<?php _e(“Image”, ‘hja’); ?>”/><input type=”button” onclick=”awQuickTags(‘<?php echo $this->get_field_id(‘hja_content’); ?>’,’','‘,”);” value=”<?php _e(“Code”, ‘hja’); ?>”/><input type=”button” onclick=”awQuickTags(‘<?php echo $this->get_field_id(‘hja_content’); ?>’,’- ‘,’
‘,”);” value=”ul”/><input type=”button” onclick=”awQuickTags(‘<?php echo $this->get_field_id(‘hja_content’); ?>’,’
- ‘,’
‘,”);” value=”ol”/><input type=”button” onclick=”awQuickTags(‘<?php echo $this->get_field_id(‘hja_content’); ?>’,’
- ‘,’
‘,”);” value=”li”/><input type=”button” onclick=”awQuickTags(‘<?php echo $this->get_field_id(‘hja_content’); ?>’,'<p>’,'</p>’,”);” value=”P”/><input type=”button” onclick=”awQuickTags(‘<?php echo $this->get_field_id(‘hja_content’); ?>’,”,'</br>’,”);” value=”br”/><input type=”button” value=”<?php _e(“Preview”, ‘hja’); ?>” class=”hja_preview_bt” /></div>
<textarea rows=”10″ id=”<?php echo $this->get_field_id(‘hja_content’); ?>” name=”<?php echo $this->get_field_name(‘hja_content’); ?>” class=”hja_content”><?php echo $hja_content; ?></textarea>
</div><div class=”section”>
<label><b><?php _e(‘Settings’, ‘hja’); ?></b></label>
<div class=”alignLeft” style=”width:47%”><label><input id=”<?php echo $this->get_field_id(‘hja_is_single’); ?>” type=”checkbox” name=”<?php echo $this->get_field_name(‘hja_is_single’); ?>” value=”1″ <?php echo $hja_is_single == “1” ? ‘checked=”checked”‘ : “”; ?> /> <?php _e(“Don’t display in Posts page”, ‘hja’); ?></label>
<label><input id=”<?php echo $this->get_field_id(‘hja_is_archive’); ?>” type=”checkbox” name=”<?php echo $this->get_field_name(‘hja_is_archive’); ?>” value=”1″ <?php echo $hja_is_archive == “1” ? ‘checked=”checked”‘ : “”; ?>/> <?php _e(“Don’t display in Archive or Tag page”, ‘hja’); ?></label>
<label><input id=”<?php echo $this->get_field_id(‘hja_is_home’); ?>” type=”checkbox” name=”<?php echo $this->get_field_name(‘hja_is_home’); ?>” value=”1″ <?php echo $hja_is_home == “1” ? ‘checked=”checked”‘ : “”; ?>/> <?php _e(“Don’t display in Home page”, ‘hja’); ?></label>
<label><input id=”<?php echo $this->get_field_id(‘hja_is_page’); ?>” type=”checkbox” name=”<?php echo $this->get_field_name(‘hja_is_page’); ?>” value=”1″ <?php echo $hja_is_page == “1” ? ‘checked=”checked”‘ : “”; ?>/> <?php _e(“Don’t display in Pages”, ‘hja’); ?></label>
<label><input id=”<?php echo $this->get_field_id(‘hja_is_search’); ?>” type=”checkbox” name=”<?php echo $this->get_field_name(‘hja_is_search’); ?>” value=”1″ <?php echo $hja_is_search == “1” ? ‘checked=”checked”‘ : “”; ?>/> <?php _e(“Don’t display in Search page”, ‘hja’); ?></label>
<label><input id=”<?php echo $this->get_field_id(‘hja_add_para’); ?>” type=”checkbox” name=”<?php echo $this->get_field_name(‘hja_add_para’); ?>” value=”1″ <?php echo $hja_add_para == “1” ? ‘checked=”checked”‘ : “”; ?>/> <?php _e(“Automatically add paragraphs”, ‘hja’); ?></label>
</div>
<div class=”alignLeft” style=”width:47%”>
<label><input id=”<?php echo $this->get_field_id(‘hja_is_admin’); ?>” type=”checkbox” name=”<?php echo $this->get_field_name(‘hja_is_admin’); ?>” value=”1″ <?php echo $hja_is_admin == “1” ? ‘checked=”checked”‘ : “”; ?>/> <?php _e(“Don’t display to admin”, ‘hja’); ?></label>
<label><?php _e(“Don’t show in posts”, ‘hja’); ?>
<input id=”<?php echo $this->get_field_id(‘hja_diable_post’); ?>” type=”text” name=”<?php echo $this->get_field_name(‘hja_diable_post’); ?>” value=”<?php echo $hja_diable_post; ?>” class=”widefat”/>
<span class=”smallText”><?php _e(“Post ID’s / name / title seperated by comma”, ‘hja’); ?></span>
</label></div>
<div style=”clear:both”></div>
</div><div class=”widget-control-actions links”>
” target=”_blank” class=”donateBt”><?php _e(“Make Donations”, ‘hja’); ?> | <?php _e(“Documentation”, ‘hja’); ?> | <?php _e(“Visit Author site”, ‘hja’); ?> | <?php _e(“Support Forum”, ‘hja’); ?> | <?php _e(“Subscribe”, ‘hja’); ?> | <?php _e(“Promote”, ‘hja’); ?></div><?php
}function hja_link_back(){
$hja_options = get_option(‘hja_data’);if(!defined(‘IS_HJA_ADDED’) && $hja_options[‘hja_disable_linkback’] != 1){
return “n” . ‘ ?‘;
}
}}
## End classfunction html_javascript_adder_init(){
register_widget(‘html_javascript_adder_widget’);
}
add_action(‘widgets_init’, ‘html_javascript_adder_init’);function html_javascript_adder_js(){
global $hja_pluginpath;
$currentUrl = $_SERVER[“PHP_SELF”];
$fileUrl = explode(‘/’, $currentUrl);
$fileName = $fileUrl[count($fileUrl) – 1];if($fileName == ‘widgets.php’){
echo ‘<script type=”text/javascript” src=”‘ . $hja_pluginpath . ‘js/awQuickTag.js”></script>’;
echo ‘<link rel=”stylesheet” href=”‘ . $hja_pluginpath . ‘hja-widget-css.css” type=”text/css” />’;
echo ‘<script type=”text/javascript” src=”‘ . $hja_pluginpath . ‘hja-widget-js.js”></script>’;
}
}
add_action(‘admin_head’,’html_javascript_adder_js’);## Action Links
function hja_plugin_actions($links, $file){
static $this_plugin;
global $hja_donate_link;if(!$this_plugin) $this_plugin = plugin_basename(__FILE__);
if( $file == $this_plugin ){
$settings_link = “” . __(‘Make Donations’, ‘hja’) . ‘ ‘;
$links = array_merge(array($settings_link), $links);
}
return $links;
}
add_filter(‘plugin_action_links’, ‘hja_plugin_actions’, 10, 2);function hja_admin_page(){
$hja_options = get_option(‘hja_data’);if ($_POST[“hja_admin_submit”]) {
$hja_options[‘hja_disable_linkback’] = $_POST[‘hja_disable_linkback’];
update_option(“hja_data”, $hja_options);
}$hja_disable_linkback = $hja_options[‘hja_disable_linkback’];
?>
<div class=”wrap”>
<form method=”POST”>
<small><label><?php _e(‘Disable HTML Javascript Adder link back’, ‘hja’); ?> <input name=”hja_disable_linkback” type=”checkbox” id=”hja_disable_linkback” value=”1″ <?php echo $hja_disable_linkback == “1” ? ‘checked=”checked”‘ : “”; ?> /></label></small>
<span class=”submit”><input type=”submit” name=”hja_admin_submit” id=”hja_admin_submit” value=”<?php _e(‘Save’); ?>” /></span></form>
</div><?php
}
add_action(‘sidebar_admin_page’, ‘hja_admin_page’);## Admin Dashboard
if(!function_exists(‘aw_dashboard’)){
function aw_dashboard() {
$rss = array(‘url’ => ‘http://feeds2.feedburner.com/aakashweb’, ‘items’ => ‘5’,’show_date’ => 0, ‘show_summary’=> 1);
$subscribe = “window.open(‘http://feedburner.google.com/fb/a/mailverify?uri=aakashweb’, ‘win’,’menubar=1,resizable=1,width=600,height=500′); return false;” ;
echo ‘<div class=”rss-widget”>’;
echo ‘<img src=”http://a.imageshack.us/img844/5834/97341029.png” align=”right”/>‘;
echo ‘<p>’; wp_widget_rss_output($rss); echo ‘</p>’;
echo ‘<hr style=”border-top: 1px solid #fff;”/>’;
echo ‘<p>‘ . __( ‘Subscribe to Updates’, ‘hja’) . ‘ | ‘ . __( ‘Follow on Twitter’, ‘aryan’) . ‘ | ‘ . __( ‘Home Page’, ‘aryan’) . ‘</p>’;
echo “</div>”;
}function aw_dashboard_setup() {
wp_add_dashboard_widget(‘aw_dashboard’, __( ‘AW Latest Updates’, ‘aryan’), ‘aw_dashboard’);
}
add_action(‘wp_dashboard_setup’, ‘aw_dashboard_setup’);
}?>
The blog I need help with is: (visible only to logged in users)
-
Hello!
Please read this support article about forbidden code:
If you try to use a dangerous code, wp.com will strip it out.
http://en.support.wordpress.com/code/
JavaScriptUsers are not allowed to post JavaScript on WordPress.com blogs. JavaScript can be used for malicious purposes. As an example, JavaScript has taken sites such as MySpace.com and LiveJournal offline in the past. The security of all WordPress.com blogs is a top priority for us, and until we can guarantee scripting languages will not be harmful, they will not be permitted.
-
Oh, nevermind. You are asking about a self-hosted site using wp.ORG software. This forum is for wp.COM free hosted blogs.
http://www.aakashweb.com/
Please head over to the wp.ORG support forum for help. We cannot advise you here:
- The topic ‘widget javascript’ is closed to new replies.