Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Socrates Premium Theme for Wordpress
- * (c) 2012 Handy Investments LLC
- * http://www.socratestheme.com
- * Version 3.04
- *
- * @File functions.php
- *
- *
- Theme Name: Socrates
- */
- $CURRENT_VERSION = '3.04';
- // Set path to theme specific functions
- $functions_path = TEMPLATEPATH . '/functions/';
- // Theme Options Panel
- require_once($functions_path . 'panel/themeoptions.php');
- // General
- add_theme_support('post-thumbnails'); // Featured Image Support
- require_once($functions_path . 'sidebars.php'); // Register Sidebars
- require_once($functions_path . 'menus.php'); // Menus WP 3.0
- require_once($functions_path . 'native.php'); // Native Image Sizing
- require_once($functions_path . 'load-scripts.php'); // Load Scripts and CSS
- require_once($functions_path . 'excerpts.php'); // Excerpt Lengths
- require_once($functions_path . 'custom-fields.php'); // Custom Fields
- require_once($functions_path . 'pagenavi.php'); // Custom Fields
- // Drag and Drop Contact Forms
- require_once($functions_path . 'ajax-contact/ajax-contact.php');
- // Shortcodes
- require_once($functions_path . 'shortcodes/shortcodes.php'); // Shortcodes
- require_once($functions_path . 'shortcodes/buttons-shortcode.php'); // Button Shortcode
- require_once($functions_path . 'shortcodes/framed-box.php'); // Framed Box Shortcode
- require_once($functions_path . 'shortcodes/action.php'); // Action
- require_once($functions_path . 'shortcodes/testimonials.php'); // Testimonial Slider
- require_once($functions_path . 'widgets/video-sidebar-widgets/video-sidebar-widgets.php'); // Video Widget
- // Shortcode Editor Buttons
- require_once($functions_path . 'shortcodes/editor/buttons/tinyMCE.php');
- require_once($functions_path . 'shortcodes/editor/testimonial/tinyMCE.php');
- require_once($functions_path . 'shortcodes/editor/alert/tinyMCE.php');
- if (!function_exists('file_put_contents_socrates')) {
- function file_put_contents_socrates($filename, $data) {
- $f = @fopen($filename, 'w');
- if (!$f) {
- return false;
- } else {
- $bytes = fwrite($f, $data);
- fclose($f);
- return $bytes;
- }
- }
- }
- if (!function_exists('file_get_contents_socrates')) {
- function file_get_contents_socrates($url) {
- $timeout = 30;
- $curl = curl_init();
- curl_setopt($curl, CURLOPT_URL, $url);
- curl_setopt($curl, CURLOPT_TIMEOUT, $timeout);
- curl_setopt($curl, CURLOPT_USERAGENT, sprintf("Mozilla/%d.0", rand(4, 5)));
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
- $html = curl_exec($curl);
- curl_close($curl);
- return $html;
- }
- }
- function is_active($silent = false) {
- $activation = get_option("socratesactivation");
- $activationcache = get_option("socratesactivationcache");
- $version = get_option("socratesversion");
- if (!is_array($activation)) {return false;} else if ( ($activationcache['time'] > (time()-86400)) && ($activationcache[0] == 'SUCCESS')) {return true;}
- else {
- $curl_handle = curl_init();
- $activateurl = 'http://drm.socratestheme.com/validate.php?code=' . $activation['code'] . '&sitelocation=' . get_bloginfo('url') . '&version=' . $version['version'];
- curl_setopt($curl_handle, CURLOPT_URL, $activateurl);
- curl_setopt($curl_handle, CURLOPT_TIMEOUT, '3');
- curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
- $buffer = curl_exec($curl_handle);
- curl_close($curl_handle);
- $newVersion = FALSE;
- if (empty($buffer)) {$buffer = 'UNKNOWN';}
- else {
- $split = explode('%', $buffer);$split['time'] = time();
- update_option("socratesactivationcache", $split);
- if ((count($split) == 3) && ($split[0] == 'SUCCESS')) {
- return true;
- } else {
- if (!$silent) {
- echo '<strong>Activation Error: ' . $split[1] . '</strong><br>';
- }
- return false;
- }
- }
- }
- return true;
- }
- function soc_activate_form() {
- $activation = get_option("socratesactivation");
- if ($_POST['activate-submit']) {
- $activation['code'] = $_POST['soc-activationcode'];
- update_option("socratesactivation", $activation);
- } else {
- echo '<form name="socrates" method="post" enctype="multipart/form-data" action="' . $_SERVER['REQUEST_URI'] . '">';
- echo '<input type="text" name="soc-activationcode" id="soc-activationcode" value="' . $activation['code'] . '">';
- echo '<input type="hidden" id="activate-submit" name="activate-submit" value="1">';
- echo '<input name="save" value="Activate" type="submit">';
- echo '</form>';
- }
- }
- function socrates_dashboard_widget_function() {
- global $CURRENT_VERSION,$wpdb;
- include_once(ABSPATH . WPINC . '/rss.php');
- $rss_feed = "http://www.socratestheme.com/dashboard/rss.xml";
- if ($_POST['activate-submit']) {
- soc_activate_form();
- }
- echo "<div id='identity'></div>";
- if (!is_active()) {
- $_POST['activate-submit'] = false;
- echo "<b>ENTER ACTIVATION CODE:</b> This copy of Socrates is not active, please activate it by entering your Activation code below:";
- soc_activate_form();
- } else {
- $curl_handle = curl_init();
- curl_setopt($curl_handle, CURLOPT_URL, 'http://www.socratestheme.com/dashboard/currentversion.html');
- curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
- $buffer = curl_exec($curl_handle);
- curl_close($curl_handle);
- $newVersion = FALSE;
- if (empty($buffer)) {
- $buffer = 'UNKNOWN';
- } else {
- $result = preg_match('/[0-9]+\.[0-9]+/', $buffer);
- if ($result == FALSE) {
- $buffer = 'REGEX_ERROR';
- } else if ($result == 0) {
- $buffer = 'REGEX_MISMATCH';
- } else if ($result == 1) {
- if ($CURRENT_VERSION < $buffer) {
- $newVersion = TRUE;
- }
- }
- }
- if ($newVersion == TRUE) {
- echo '<strong>An updated version of the Socrates theme is available <a href="http://www.socratestheme.com/downloads">here.</a></strong><br>';
- } else {
- echo 'Your installation is up to date. ';
- }
- echo 'Installed Version: ' . $CURRENT_VERSION . ' Latest Version: ' . $buffer . '<br><br>';
- echo "<ul>";
- $rss = fetch_rss($rss_feed);
- $rss->items = array_slice($rss->items, 0, 6);
- $channel = $rss->channel;
- foreach ($rss->items as $item) {
- $parsed_url = parse_url(wp_filter_kses($item['link']));
- echo "<li><b><a href=" . wp_filter_kses($item['link']) . ">" . wptexturize(wp_specialchars($item['title'])) . "</a></b></li>";
- }
- echo "</ul>";
- $activation = get_option("socratesactivation");
- $activationcache = get_option("socratesactivationcache");
- echo '<br>' . $activationcache[1] . '<br>';
- echo 'Activation Code: ' . $activation['code'];
- }
- }
- function socrates_activation_widget_function() {
- global $wpdb;
- echo "<div id='identity'></div>";
- echo '<style>.socactivation {background:#FFFFFF; display:block; z-index:99; top:0; left:0; bottom:0; right:0; margin:0; padding:0; position:absolute; color:#000000; width:100%; height:100%;}</style>';
- $activation = get_option("socratesactivation");
- $version = get_option("socratesversion");
- if (!is_array($activation)) {
- echo '<div class="socactivation">Please enter your activation code</div>';
- } else {
- $curl_handle = curl_init();
- $activateurl = 'http://drm.socratestheme.com/validate.php?code=' . $activation['code'] . '&sitelocation=' . get_bloginfo('url') . '&version=' . $version['version'];
- curl_setopt($curl_handle, CURLOPT_URL, $activateurl);
- curl_setopt($curl_handle, CURLOPT_TIMEOUT, '3');
- curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
- $buffer = curl_exec($curl_handle);
- curl_close($curl_handle);
- $newVersion = FALSE;
- if (empty($buffer)) {
- $buffer = 'UNKNOWN';
- } else {
- $split = explode('%', $buffer);
- if (count($split) == 2) {
- if ($split[0] == 'SUCCESS') {
- echo $split[1];
- } else {
- echo '<div class="socactivation">' . $split[0] . '<br>' . $split[1] . '<br><br>Please enter your activation code</div>';
- }
- }
- }
- }
- }
- function custom_footer() {
- ?>
- <p class="credit"><a href="http://iwp.ro" title="Wordpress Tutorials">Wordpress Tutorials</a> | <a href="http://www.dream-webdesign.ro" title="Design web">Design web</a> | <a href="http://valanz.com" title="Free website design">Free website design</a> | <a href="http://iwp.ro/site-gratis" title="Site Gratis">Site Gratis</a></p>
- <?php }
- // Create the function use in the action hook
- function add_socrates_dashboard_widget() {
- global $CURRENT_VERSION;
- $versionSetting['version'] = $CURRENT_VERSION;
- update_option("socratesversion", $versionSetting);
- wp_add_dashboard_widget('socrates_dashboard_widget', 'Socrates Theme News', 'socrates_dashboard_widget_function');
- // Globalize the metaboxes array, this holds all the widgets for wp-admin
- global $wp_meta_boxes;
- // Get the regular dashboard widgets array
- // (which has our new widget already but at the end)
- $normal_dashboard = $wp_meta_boxes['dashboard']['normal']['core'];
- // Backup and delete our new dashbaord widget from the end of the array
- $example_widget_backup = array(
- 'socrates_dashboard_widget' => $normal_dashboard['socrates_dashboard_widget']
- );
- unset($normal_dashboard['socrates_dashboard_widget']);
- // Merge the two arrays together so our widget is at the beginning
- $sorted_dashboard = array_merge($example_widget_backup, $normal_dashboard);
- // Save the sorted array back into the original metaboxes
- $wp_meta_boxes['dashboard']['normal']['core'] = $sorted_dashboard;
- }
- // Hook into the 'wp_dashboard_setup' action to register our other functions
- add_action('wp_dashboard_setup', 'add_socrates_dashboard_widget');
- function customize_meta_boxes() {
- //retrieve current user info
- global $current_user;
- get_currentuserinfo();
- //if current user level is less than 3, remove the postcustom meta box
- if ($current_user->user_level < 10)
- remove_meta_box('socrates_dashboard_widget', 'dashboard', 'normal');
- }
- add_action('admin_init', 'customize_meta_boxes');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement