Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Innovation Plugin
#1
Needed to extend Innovation Theme plugin with some Dutch Social Networks and remove some others. As a lazy developer as I am I've inserted an array into the plugin and changed the code for dynamical reading.

Code:
<?php
/*
Plugin Name: Innovation Theme Settings
Description: Settings for the default GetSimple 3.0 Theme: Innovation
Version: 1.1
Author: Chris Cagle
Author URI: http://www.cagintranet.com/
*/

# get correct id for plugin
$thisfile_innov=basename(__FILE__, ".php");
$innovation_file=GSDATAOTHERPATH .'InnovationSettings.xml';

# add in this plugin's language file
i18n_merge($thisfile_innov,'en_US');

# register plugin
register_plugin(
    $thisfile_innov,                                                     # ID of plugin, should be filename minus php
    i18n_r($thisfile_innov.'/INNOVATION_TITLE'),                 # Title of plugin
    '1.1',                                                             # Version of plugin
    'Chris Cagle',                                            # Author of plugin
    'http://www.cagintranet.com/',             # Author URL
    i18n_r($thisfile_innov.'/INNOVATION_DESC'),                     # Plugin Description
    'theme',                                                         # Page type of plugin
    'innovation_show'                                      # Function that displays content
);

# hooks
add_action('theme-sidebar','createSideMenu',array($thisfile_innov, i18n_r($thisfile_innov.'/INNOVATION_TITLE')));

# change /add / remove your Social Networks here ...
$innovation = Array('facebook','twitter','linkedin','hyves','plaxo');

# get XML data
if (file_exists($innovation_file)) {
    $x = getXML($innovation_file);
    foreach($innovation as $key => $value) {
        $social[$value] = $x->$value;
    }
} else {
    foreach($innovation as $key => $value) {
        $social[$value] = '';
    }
}


function innovation_show() {
    global $innovation_file, $thisfile_innov, $innovation, $social;
    
    // submitted form
    if (isset($_POST['submit'])) {
        foreach($innovation as $key => $value) {
            $social[$value] = null;
        }
        
        # check to see if the URLs provided are valid
        foreach($innovation as $key => $value) {
            if ($_POST[$value] != '') {
                if (validate_url($_POST[$value])) {
                    $social[$value] = $_POST[$value];
                } else {
                    $error .= i18n_r($thisfile_innov.'/'.strtoupper($value).'_ERROR').' ';
                }
            }
        }
        
        # if there are no errors, dave data
        if (!$error) {
            $xml = @new SimpleXMLElement('<item></item>');
            foreach($innovation as $key => $value) {
                $xml->addChild($value, $social[$value]);
            }
            if (! $xml->asXML($innovation_file)) {
                $error = i18n_r('CHMOD_ERROR');
            } else {
                $x = getXML($innovation_file);
                foreach($innovation as $key => $value) {
                    $social[$value] = $x->$value;
                }
                $success = i18n_r('SETTINGS_UPDATED');
            }
        }
    }
    
    ?>
    <h3><?php i18n($thisfile_innov.'/INNOVATION_TITLE'); ?></h3>
    
    <?php
    if($success) {
        echo '<p style="color:#669933;"><b>'. $success .'</b></p>';
    }
    if($error) {
        echo '<p style="color:#cc0000;"><b>'. $error .'</b></p>';
    }
    ?>
    
    <form method="post" action="<?php echo $_SERVER ['REQUEST_URI']?>">
        <?php foreach($innovation as $key => $value) { ?>
            <p><label for="inn_<?php echo $value ?>" ><?php i18n($thisfile_innov.'/'.strtoupper($value).'_URL'); ?></label><input id="inn_<?php echo $value ?>" name="<?php echo $value ?>" class="text" value="<?php echo $social[$value]; ?>" /></p>
        <?php } ?>
        <p><input type="submit" id="submit" class="submit" value="<?php i18n('BTN_SAVESETTINGS'); ?>" name="submit" /></p>
    </form>
    
    <?php
}
Reply


Messages In This Thread
Innovation Plugin - by Rene - 2011-05-03, 05:58:46
RE: Innovation Plugin - by cmscss - 2012-11-06, 21:20:12
RE: Innovation Plugin - by Carlos - 2012-11-07, 06:24:22
RE: Innovation Plugin - by Oleg06 - 2012-11-07, 08:23:39
RE: Innovation Plugin - by Carlos - 2012-11-07, 16:50:15
RE: Innovation Plugin - by Oleg06 - 2012-11-07, 18:59:19
RE: Innovation Plugin - by Carlos - 2012-11-08, 04:21:28
RE: Innovation Plugin - by Oleg06 - 2012-11-08, 06:18:25
RE: Innovation Plugin - by cmscss - 2012-11-08, 06:26:07
RE: Innovation Plugin - by Oleg06 - 2012-11-08, 16:19:59
RE: Innovation Plugin - by cmscss - 2012-11-11, 09:15:42
RE: Innovation Plugin - by Oleg06 - 2012-11-11, 15:53:16
RE: Innovation Plugin - by shawn_a - 2012-11-12, 01:38:15
RE: Innovation Plugin - by shawn_a - 2013-04-12, 02:11:34
RE: Innovation Plugin - by Oleg06 - 2014-03-13, 21:00:26
RE: Innovation Plugin - by shawn_a - 2014-03-13, 22:19:04
RE: Innovation Plugin - by Oleg06 - 2014-03-13, 22:25:38
RE: Innovation Plugin - by shawn_a - 2014-03-14, 03:26:59
RE: Innovation Plugin - by shawn_a - 2014-03-14, 03:39:40
RE: Innovation Plugin - by shawn_a - 2014-03-14, 04:12:15
RE: Innovation Plugin - by Oleg06 - 2014-03-14, 04:30:01
Innovation Plugin - by alienee2 - 2012-04-17, 22:37:17



Users browsing this thread: 3 Guest(s)