Permalink
Browse files

version 1.0 is done

  • Loading branch information...
0 parents commit a3e1c5d0a0750830151ea182f4d147536b65c568 @eftakhairul committed Sep 28, 2012
29 git-portfolio.php
@@ -0,0 +1,29 @@
+<?php
+/*
+Plugin Name: Git Portfolio
+Plugin URI: https://github.com/eftakhairul/WP-Plugins/tree/master/Git-Portfolio
+Description: This plugin will help you to showcase your projects on Git as widget.
+Version: 1.0
+Author: Eftakhairul Islam, Sirajus Salayhin & Prince Faisal Ahmed
+Author URI: http://eftakhairul.com (Eftakhairul), http://salayhin.com (Salayhin)
+License: GPL2
+*/
+include_once('installation_plugin.php');
+include_once('installation-widget.php');
+
+register_activation_hook(__FILE__, 'esp_git_portfolio_install');
+register_deactivation_hook(__FILE__, 'esp_git_portfolio_uninstall');
+
+add_action('admin_menu', 'esp_git_portfolio_create_menu');
+add_action('widgets_init', 'esp_git_portfolio_load_widget');
+
+function esp_git_portfolio_create_menu()
+{
+ $main_option_page = __FILE__;
+ add_menu_page('Git Portfolio Setting', 'Git Portfolio Setting', 'administrator', 'project-portfolio-setting', 'esp_portfolio_setting',plugins_url('/Git-Portfolio/images/icon_pref_settings.gif','portfolio-setting'));
+}
+
+function esp_portfolio_setting()
+{
+ include("git_portfolio_setting.php");
+}
109 git_portfolio_setting.php
@@ -0,0 +1,109 @@
+<?php
+
+global $wpdb;
+
+$projectPortFolioTable = $wpdb->prefix . "project_portfolio";
+settings_fields('portfolio-setting');
+
+//Update submit value
+if (!empty($_POST)) {
+
+ for($cnt = 0; $cnt < 5; $cnt++)
+ {
+ $wpdb->update($projectPortFolioTable, array(
+ 'project_name' => $_POST['project_name'][$cnt],
+ 'project_image' => $_POST['project_image'][$cnt],
+ 'project_link' => $_POST['project_link'][$cnt],
+ ), array('project_portfolio_id' => $_POST['id'][$cnt]));
+ }
+}
+
+// Define form value
+$data = $wpdb->get_results("SELECT * FROM $projectPortFolioTable");
+$result = array();
+for($cnt = 0; $cnt < 5; $cnt++)
+{
+ $result[$cnt]['project_name'] = (!empty($_POST['project_name'][$cnt])) ? $_POST['project_name'][$cnt] : $data[$cnt]->project_name;
+ $result[$cnt]['project_image'] = (!empty($_POST['project_image'][$cnt])) ? $_POST['project_image'][$cnt] : $data[$cnt]->project_image;
+ $result[$cnt]['project_link'] = (!empty($_POST['project_link'][$cnt])) ? $_POST['project_link'][$cnt] : $data[$cnt]->project_link;
+}
+?>
+
+<div class="wrap">
+ <h2>Git Portfolio Setting</h2>
+
+ <?php if(!empty($_POST)) : ?>
+ <div class="updated inline below-h2">
+ <p> Your setting is updated successfully. </p>
+ </div>
+ <br/>
+ <?php endif; ?>
+
+ <form method="post" action="<?php echo $_SERVER['REQUEST_URI']?>">
+ <?php wp_nonce_field('update-options'); ?>
+
+ <table width="100%">
+ <thead>
+ <tr>
+ <td></td>
+ <td>Git Project Name</td>
+ <td>Git Project Thumb Image Link</td>
+ <td>Git Project Source Link</td>
+ </tr>
+ </thead>
+
+ <tbody>
+ <tr>
+ <td>Project-1</td>
+ <td>
+ <input type="text" name='project_name[]' value="<?php echo $result[0]['project_name'] ?>" />
+ <input type="hidden" name='id[]' value = '1' />
+ </td>
+ <td><input type="text" name='project_image[]' value="<?php echo $result[0]['project_image'] ?>" /></td>
+ <td><input type="text" name='project_link[]' value="<?php echo $result[0]['project_link'] ?>" /></td>
+ </tr>
+ <tr>
+ <td>Project-2</td>
+ <td>
+ <input type="text" name='project_name[]' value="<?php echo $result[1]['project_name'] ?>" />
+ <input type="hidden" name='id[]' value = '2' />
+ </td>
+ <td><input type="text" name='project_image[]' value="<?php echo $result[1]['project_image'] ?>" /></td>
+ <td><input type="text" name='project_link[]' value="<?php echo $result[1]['project_link'] ?>" /></td>
+ </tr>
+ <tr>
+ <td>Project-3</td>
+ <td>
+ <input type="text" name='project_name[]' value="<?php echo $result[2]['project_name'] ?>" />
+ <input type="hidden" name='id[]' value = '3' />
+ </td>
+ <td><input type="text" name='project_image[]' value="<?php echo $result[2]['project_image'] ?>" /></td>
+ <td><input type="text" name='project_link[]' value="<?php echo $result[2]['project_link'] ?>" /></td>
+ </tr>
+ <tr>
+ <td>Project-4</td>
+ <td>
+ <input type="text" name='project_name[]' value="<?php echo $result[3]['project_name'] ?>" />
+ <input type="hidden" name='id[]' value = '4' />
+ </td>
+ <td><input type="text" name='project_image[]' value="<?php echo $result[3]['project_image'] ?>"/></td>
+ <td><input type="text" name='project_link[]' value="<?php echo $result[3]['project_link'] ?>"/></td>
+ </tr>
+ <tr>
+ <td>Project-5</td>
+ <td>
+ <input type="text" name='project_name[]' value="<?php echo $result[4]['project_name'] ?>" />
+ <input type="hidden" name='id[]' value = '5' />
+ </td>
+ <td><input type="text" name='project_image[]' value="<?php echo $result[4]['project_image'] ?>" /></td>
+ <td><input type="text" name='project_link[]' value="<?php echo $result[4]['project_link'] ?>" /></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+ <div style="padding: 30px 0px 0px 400px;"><input type="submit" class="button-primary" name="save-project-portfolio"
+ value="<?php _e('Save Changes') ?>"/> </div>
+ <input type="hidden" name="action" value="update"/>
+ </form>
+</div>
BIN images/github.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN images/icon_pref_settings.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
109 installation-widget.php
@@ -0,0 +1,109 @@
+<?php
+
+
+
+function esp_git_portfolio_load_widget()
+{
+ register_widget('ProjectPortfolio');
+}
+
+class ProjectPortfolio extends WP_Widget
+{
+
+ function ProjectPortfolio()
+ {
+ $widget_ops = array('classname' => 'projectportfolio', 'description' => __('Project prtfolio settings', 'projectportfolio'));
+ $control_ops = array('width' => 300, 'height' => 350, 'id_base' => 'project-portfolio-widget');
+ $this->WP_Widget('project-portfolio-widget', __('Git portfolio', 'projectportfolio'), $widget_ops, $control_ops);
+ }
+
+
+ function widget($args, $instance)
+ {
+ global $wpdb;
+
+ $portfolioRefTable = $wpdb->prefix ."project_portfolio" ;
+ $data = $wpdb->get_results("SELECT * FROM {$portfolioRefTable}");
+
+
+
+ extract($args);
+
+ $portfolioTitle = apply_filters('project_portfolio_widget_title', $instance['project_portfolio_widget_title']);
+
+ echo $before_widget;
+ echo $before_title . $portfolioTitle . $after_title;
+?>
+ <table border="0" style="clear: both;">
+<?php
+
+for($cnt = 0; $cnt < 5; $cnt++)
+{
+if((!empty($data[$cnt]->project_name)) AND (!empty($data[$cnt]->project_link))){
+?>
+
+
+ <tr>
+ <td>
+ <div >
+ <?php if (!empty($data[$cnt]->project_image)){ ?>
+ <a href="<?php echo (!empty($data[$cnt]->project_link)) ? $data[$cnt]->project_link : ''; ?>"><img src="<?php echo $data[$cnt]->project_image ; ?>" width="220px" height="150px"/></a>
+ <?php }else{ ?>
+ <a href="<?php echo (!empty($data[$cnt]->project_link)) ? $data[$cnt]->project_link : ''; ?>"><img src="<?php echo site_url(); ?>/wp-content/plugins/Git-Portfolio/images/github.jpg" /></a>
+ <?php } ?>
+ </div>
+ </td>
+ </tr>
+
+ <tr>
+ <td>&nbsp;</td>
+ </tr>
+
+ <tr>
+ <td><b><?php echo (!empty($data[$cnt]->project_name)) ? $data[$cnt]->project_name : ''; ?></b></td>
+ </tr>
+
+ <tr>
+ <td>Source:&nbsp;<a href="<?php echo (!empty($data[$cnt]->project_link)) ? $data[$cnt]->project_link : ''; ?>" class=""><?php echo (!empty($data[$cnt]->project_link)) ? $data[$cnt]->project_link : ''; ?></a></td>
+ </tr>
+
+ <tr>
+ <td ><hr width="100%"/></td>
+
+ </tr>
+
+
+<?php
+ }
+}
+?>
+</table>
+<?php
+ echo $after_widget;
+
+ }
+
+ function update($new_instance, $old_instance)
+ {
+ $instance = $old_instance;
+ $instance['project_portfolio_widget_title'] = $new_instance['project_portfolio_widget_title'];
+ return $instance;
+ }
+
+ function form($instance)
+ {
+
+ $defaults = array('project_portfolio_widget_title' => __('', 'projectportfolio'));
+ $instance = wp_parse_args((array)$instance, $defaults);?>
+ <p>
+ <label for="<?php echo $this->get_field_id('project_portfolio_widget_title'); ?>">
+ <?php _e('Enter Widget Title', 'hybrid'); ?>
+ </label>
+ <input type="text" id="<?php echo $this->get_field_id('project_portfolio_widget_title'); ?>"
+ name="<?php echo $this->get_field_name('project_portfolio_widget_title'); ?>" style="width:100%;"
+ value="<?php echo $instance['project_portfolio_widget_title']; ?>"/>
+ </p>
+<?php
+ }
+}
+?>
44 installation_plugin.php
@@ -0,0 +1,44 @@
+<?php
+
+global $version;
+$version = "3.0";
+
+// Installation Function
+function esp_git_portfolio_install()
+{
+ global $version, $wpdb;
+
+ if (!version_compare($version, '3.0', '>=')) {
+
+ error_log('Please install version greater than 3.0');
+ echo 'Please install version greater than 3.0';
+ }
+
+ $projectPortFolioTable = $wpdb->prefix . "project_portfolio";
+ $createTableSql = "CREATE TABLE `{$projectPortFolioTable}` (
+ `project_portfolio_id` TINYINT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
+ `project_name` VARCHAR( 100 ) NULL ,
+ `project_image` VARCHAR( 100 ) NULL ,
+ `project_link` TEXT NULL ,
+ `update_date` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL
+ ) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci;";
+
+ $insertSql = "INSERT INTO `{$projectPortFolioTable}` (`project_portfolio_id`, `project_name`, `project_image`, `project_link`, `update_date`) VALUES ('1', NULL, NULL, NULL, '0000-00-00 00:00:00'), ('2', NULL, NULL, NULL, '0000-00-00 00:00:00'), ('3', NULL, NULL, NULL, '0000-00-00 00:00:00'), ('4', NULL, NULL, NULL, '0000-00-00 00:00:00'), ('5', NULL, NULL, NULL, '0000-00-00 00:00:00');";
+
+ require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
+ dbDelta($createTableSql);
+ dbDelta($insertSql);
+}
+
+// Un-installation Function
+function esp_git_portfolio_uninstall()
+{
+ global $wpdb;
+
+ $projectPortFolioTable = $wpdb->prefix . "project_portfolio";
+
+ if ($wpdb->get_var("show tables like '{$projectPortFolioTable}'") == $projectPortFolioTable) {
+ $sql = "DROP TABLE {$projectPortFolioTable}";
+ $wpdb->query($sql);
+ }
+}
4 readme.md
@@ -0,0 +1,4 @@
+Git Portfolio
+
+====================================================================
+This is very simple plugin that you helps to showcase your Github Projects as widget in your blog.

0 comments on commit a3e1c5d

Please sign in to comment.