Plugin Directory

Changeset 1088397


Ignore:
Timestamp:
02/12/2015 07:18:43 PM (11 years ago)
Author:
ishimwe
Message:

Updated to version 3.0.5

Location:
sidebar-post/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sidebar-post/trunk/readme.txt

    r1071877 r1088397  
    55Requires at least: Wordpress 3.0
    66Tested up to: Wordpress 4.1
    7 Stable tag: 3.0.4
     7Stable tag: 3.0.5
    88
    99This plugin allows your visitors (logged in OR Not) to submit posts to your site via a simple sidebar widget form.
     
    8181* Fixed formatting issues
    8282
     83=3.0.5=
     84
     85* Added a fully working Uninstaller
     86* Fixed two unnecessary loops
     87
    8388== Upgrade Notice ==
    8489
  • sidebar-post/trunk/sidebar_post.php

    r1071877 r1088397  
    44Plugin URI: http://www.wpcoding.ca
    55Description: This plugin places a posting form in the sidebar
    6 Version: 3.0.4
     6Version: 3.0.5
    77Author: Janvier M @ WpCoding .Ca
    88Author URI: http://www.wpcoding.ca
     
    1818global $shortname;
    1919$shortname = "spost_";
    20 define('SPOST_VERSION','3.0.4');
    21 define('SPOST_DATABASE_VERSION','3.0.4');
    22 define('SPOST_BUILD','01202015');
     20
     21define('SPOST_VERSION','3.0.5');
     22define('SPOST_DATABASE_VERSION','3.0.5');
     23define('SPOST_BUILD','02122015');
    2324define('SOFTWARE_NAME',__('Sidebar Post','spost'));
    2425define( 'SPOST_PLUGIN_DIR', WP_PLUGIN_DIR . '/sidebar-post' );
    2526define( 'SPOST_PLUGIN_URL', WP_PLUGIN_URL . '/sidebar-post' );
    2627
     28define( 'NEXUS_FRAMEWK_DIR', SPOST_PLUGIN_DIR . '/nexusframework' );
     29define( 'NEXUS_FRAMEWK_URL', SPOST_PLUGIN_URL . '/nexusframework' );
     30define( 'SPOST_UNINSTALL_CODE','AKDJEMSL');             
    2731$site_home = get_option('home');
     32include(NEXUS_FRAMEWK_DIR.'/nexus.php');
    2833function spost_loader_activate() {
    2934    do_action( 'spost_loader_activate' );
     
    3843function spost_theme_setup(){
    3944    //load_theme_textdomain('spost', SPOST_PLUGIN_URL . '/languages');
    40     load_plugin_textdomain( 'spost', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/');
     45    load_plugin_textdomain( 'spost', false, NEXUS_FRAMEWK_URL . '/languages/');
    4146}add_action( 'init', 'spost_theme_setup' );
    4247
     
    292297    <textarea class="widefat" id="<?php echo $this->get_field_id('textarea'); ?>" name="<?php echo $this->get_field_name('textarea'); ?>"><?php echo $textarea; ?></textarea>
    293298    </p>
     299    <p>
     300    <label for="<?php echo $this->get_field_id('textarea'); ?>"><?php _e('Posting Instructions:', 'spost'); ?></label>
     301    <textarea class="widefat" id="<?php echo $this->get_field_id('textarea'); ?>" name="<?php echo $this->get_field_name('textarea'); ?>"><?php echo $textarea; ?></textarea>
     302    </p>
    294303    <?php
    295304    }
     
    343352    add_options_page('SidebarPosting', 'Sidebar Post', 'manage_options', 'sidebar-posting', 'sidebar_post_fx');
    344353}*/
    345 function spost_admin_actions() {
    346  
    347     $one = add_menu_page(__('Sidebar Post','spost'),__('Sidebar Post','spost'),'switch_themes', "spost", "spost_admin_fx", SPOST_PLUGIN_URL.'/images/icon.png', '5.4');
    348     $mainsettings = add_submenu_page('spost', __('Advanced Settings','spost'), __('Advanced Settings','spost'), 'switch_themes', 'spost-main-settings', 'spost_other_admin_options' );
    349     $uninstallspost = add_submenu_page('spost', __('Uninstall','spost'), __('Uninstall','spost'), 'switch_themes', 'spost-uninstall', 'spost_uninstall_fx' );
    350     $loginattemps = add_submenu_page('spost', __('Documentation','spost'), __('Documentation','spost'), 'switch_themes', 'spost-documentation', 'spost_documentation_fx' );
    351    
    352 add_action( 'admin_print_styles-' . $one, 'spost_plugin_enqueue_scripts' );
    353 add_action( 'admin_print_styles-' . $mainsettings, 'spost_plugin_enqueue_scripts' );
    354 add_action( 'admin_print_styles-' . $loginattemps, 'spost_plugin_enqueue_scripts' ); 
    355 add_action( 'admin_print_styles-' . $uninstallspost, 'spost_plugin_enqueue_scripts' );
    356 
    357 add_action( 'admin_head-'. $one, 'spost_header_admin' );
    358 add_action( 'admin_head-'. $mainsettings, 'spost_header_admin' );
    359 add_action( 'admin_head-'. $loginattemps, 'spost_header_admin' );
    360 add_action( 'admin_head-'. $uninstallspost, 'spost_header_admin' );
    361 
    362 }add_action('admin_menu', 'spost_admin_actions');
    363 
    364 function spost_plugin_enqueue_scripts( $hook_suffix ) {
    365     wp_enqueue_style( 'spost-admin-style', SPOST_PLUGIN_URL . '/css/spost-admin.css', false, SPOST_VERSION );
    366     wp_enqueue_script( 'spost-admin-js', SPOST_PLUGIN_URL . '/js/spost-admin.js', false, SPOST_VERSION );   
    367     wp_enqueue_script( 'spost-colorPicker-js',SPOST_PLUGIN_URL . '/js/color-picker.js', array( 'wp-color-picker' ), false, true);   
    368       // first check that $hook_suffix is appropriate for your admin page
    369     wp_enqueue_style( 'wp-color-picker' );
    370 }
    371 function spost_admin_fx(){?>
    372 <div id="spostContainer">
    373 <form id="spostForm1" enctype="multipart/form-data" method="post" action="">
    374     <div class="spostRow" id="theHeader">
    375         <h1><?php _e('Sidebar Post - Main Settings','spost'); ?></h1>
    376     </div><div class="clearall"></div>
    377     <div class="spostRow" data-spostid="spost_allowed_level">
    378         <div class="inputTitle"><?php _e('Allow Posting','spost'); ?>?</div>
    379         <div class="inputContent">
    380         <select id="spost_allowed_level" name="spost_allowed_level">
    381             <option value="everybody" <?php if(get_option('spost_allowed_level')=='everybody'){echo 'selected="selected"';} ?>><?php _e('Everybody','spost'); ?></option>
    382             <option value="loggedin" <?php if(get_option('spost_allowed_level')=='loggedin'){echo 'selected="selected"';} ?>><?php _e('Only logged in','spost'); ?></option>
    383             <option value="none" <?php if(get_option('spost_allowed_level')=='none'){echo 'selected="selected"';} ?>><?php _e('Do NOT allow','spost'); ?></option>
    384         </select></div>
    385         <div class="spostLegend"></div><div class="clearall"></div>
    386     </div><div class="clearall"></div>
    387     <div class="spostRow" data-spostid="spost_require_email">
    388         <div class="inputTitle"><?php _e('Require Email to post','spost'); ?></div>
    389         <div class="inputContent">
    390         <div class="<?php if(get_option('spost_require_email')=='1' || get_option('spost_require_email')==''){echo 'yes';}else{echo 'no';} ?>" data-toggleyesno="spost_require_email"><?php if(get_option('spost_require_email')=='1' || get_option('spost_require_email')==''){_e('Yes','spost');}else{_e('No','spost');} ?></div>
    391         <input type="hidden" name="spost_require_email" id="spost_require_email" value="<?php echo get_option('spost_require_email'); ?>" />
    392         </div>
    393         <div class="spostLegend"></div><div class="clearall"></div>
    394     </div><div class="clearall"></div>
    395     <div class="spostRow" data-spostid="spost_posting_posttype">
    396         <div class="inputTitle"><?php _e('Target Post type','spost'); ?></div>
    397         <div class="inputContent">
    398         <select name="spost_posting_posttype" id="spost_posting_posttype">
    399         <?php
    400             $post_types = get_post_types( '', 'names' );
    401            
    402             foreach ( $post_types as $post_type ) {
    403             if(get_option('spost_posting_posttype')==$post_type){
    404                echo '<option value="' . $post_type . '" selected="selected">' . $post_type . '</option>';
    405                 }else{
    406                echo '<option value="' . $post_type . '">' . $post_type . '</option>';
    407                 }
    408             }
    409 
    410          ?>
    411          </select>
    412         </div>
    413         <div class="spostLegend"></div><div class="clearall"></div>
    414     </div><div class="clearall"></div>
    415     <div class="spostRow" data-spostid="spost_posting_taxonomy">
    416         <div class="inputTitle"><?php _e('Target Taxonomy','spost'); ?></div>
    417         <div class="inputContent">
    418         <select name="spost_posting_taxonomy" id="spost_posting_taxonomy">
    419             <?php
    420             $taxonomies = get_taxonomies();
    421             foreach ( $taxonomies as $taxonomy ) {
    422             if(get_option('spost_posting_taxonomy')==$taxonomy){
    423                echo '<option value="' . $post_type . '" selected="selected">' . $taxonomy . '</option>';
    424                 }else{
    425                echo '<option value="' . $taxonomy . '">' . $taxonomy . '</option>';
    426                 }
    427             }
    428             ?>
    429         </select>
    430         </div>
    431         <div class="spostLegend"></div><div class="clearall"></div>
    432     </div><div class="clearall"></div>
    433 <div class="spostRow" data-spostid="spost_posting_status">
    434         <div class="inputTitle"><?php _e('Default Post Status','spost'); ?></div>
    435         <div class="inputContent">
    436         <select name="spost_posting_status" id="spost_posting_status">
    437             <option value="draft" <?php if(get_option('spost_posting_status')=='draft'){echo 'selected="selected"';} ?>><?php _e('Draft','spost'); ?></option>
    438             <option value="publish" <?php if(get_option('spost_posting_status')=='publish'){echo 'selected="selected"';} ?>><?php _e('Publish','spost'); ?></option>
    439            
    440         </select>
    441         </div>
    442         <div class="spostLegend"></div><div class="clearall"></div>
    443     </div><div class="clearall"></div>
    444 <div class="spostRow" data-spostid="spost_posting_default_user">
    445         <div class="inputTitle"><?php _e('Default Post user','spost'); ?></div>
    446         <div class="inputContent">
    447         <?php if(get_option('spost_posting_default_user')==''){
    448             $user = get_user_by('email', get_option('admin_email') );
    449             $selected_user = $user->ID;
    450             }else{
    451             $selected_user = get_option('spost_posting_default_user');
    452             }
    453        
    454         wp_dropdown_users(array('name' => 'spost_posting_default_user',
    455                                       'show'=> 'display_name',
    456                                       'orderby'                 => 'display_name',
    457                                       'id'                      => 'spost_posting_default_user',
    458                                       'selected'                => $selected_user,)); ?>
    459         </div>
    460         <div class="spostLegend"><?php _e('Posts from unregistred users will be assigned to this user','spost'); ?></div><div class="clearall"></div>
    461     </div><div class="clearall"></div>
    462 
    463 <div class="spostRow" data-spostid="spost_posting_taxonomy">
    464     <input type="submit" name="save_settings" id="save_settings" style="margin-left:auto; margin-right:auto; border: none; background:#333; color: #FFF; border-radius: 15px; padding:5px 25px; cursor: pointer;" value="<?php _e('Save Settings','spost'); ?>"/>    <div id="spostMessages"></div>
    465 </div><div class="clearall"></div>
    466 </form>
    467 
    468 </div><div class="clearall"></div>
    469 <?php }
    470 function spost_header_admin(){?>
    471 <script type="text/javascript">
    472 jQuery(document).ready(function($) {
    473     /************************************* AJAX AND FORM STUFF ******************************/
    474 function toggle_yesno(){
    475     var yesText = '<?php _e('Yes','spost'); ?>';
    476     var noText = '<?php _e('No','spost'); ?>';
    477     $('.inputContent div').on("click", function(event){
    478         var theElement = $(this).closest( ".spostRow" ).attr( "data-spostid" );
    479         var yesno = $(this).attr("class");
    480         if(yesno=='yes'){
    481             $(this).removeClass('yes');
    482             $(this).addClass('no');
    483             $('#'+theElement).val('0');
    484             $(this).html(noText);
    485            
    486         }else if(yesno=='no'){
    487             $(this).removeClass('no');
    488             $(this).addClass('yes');
    489             $('#'+theElement).val('1');
    490             $(this).html(yesText);
    491         }
    492        
    493     })
    494 }
    495 toggle_yesno();
    496 
    497     $('#save_settings').on("click",function(event){
    498         event.preventDefault();
    499  
    500       console.log( $(  "#spostForm1" ).serialize() ); //serialize form on client side
    501       var pdata = {
    502          action: "spostSaveSettings",
    503          postdata: $("#spostForm1").serialize(),
    504       }
    505       $.post(ajaxurl , pdata, function( response ) {
    506         //$("#spostMessage").html(data).show("slow").delay(5000).hide("slow");
    507         //$("#SidebarPost").hide();
    508          var obj = JSON.parse(response);
    509             if(obj.updatestatus=='success'){
    510                 $('#spostMessages').fadeIn().delay(5000).hide("slow");;
    511                 $('#spostMessages').html(obj.updatecontext);
    512                 $('#spostMessages').addClass('success');
    513             }else{
    514                 $('#spostMessages').fadeIn().delay(5000).hide("slow");;
    515                 $('#spostMessages').html(obj.updatecontext);
    516                 $('#spostMessages').addClass('failure');
    517             }
    518       });
    519      
    520     })
    521  $('#spost_custom_login_page option').attr('disabled','disabled');
    522  $('#spost_custom_login_page').attr('disabled','disabled');
    523     /************************************* /AJAX AND FORM STUFF ******************************/
    524 
    525 });
    526 </script>
    527 <?php }
     354
    528355function sidebar_post_fx(){
    529356
     
    672499    </div><div class="clearall"></div>
    673500    <div class="spostRow">
    674         <?php _e('Coming up in the next version','spost'); ?>
     501        <div class="warningRed">
     502        <?php _e('You are about to uninstall SideBar Post. This action is irreversible, and you will need to reactivate the plugin','spost'); ?>
     503        <p>
     504        <form id="uninstallspost" name="uninstallspost" enctype="multipart/form-data" method="post">
     505        <input type="hidden" name="finalUninstallSpost" value="<?PHP echo SPOST_UNINSTALL_CODE; ?>" />
     506       
     507        <button name="uninstallit1" id="uninstallit1"><?php _e('You really want to uninstall?','spost'); ?></button><button type="submit" name="uninstallit" id="uninstallit"  disabled="disabled"><?php _e('Finish the Uninstall','spost'); ?></button>
     508        </form>
     509        </div>
     510       
    675511        <div class="clearall"></div>
    676512    </div><div class="clearall"></div>
     
    742578}
    743579add_action('wp_ajax_spostSaveSettings', 'save_spost_settings');
    744 
     580function uninstall_spost_last(){
     581    if($_POST['finalUninstallSpost']!=SPOST_UNINSTALL_CODE){
     582       
     583    }else{
     584 
     585$spostOptions = array(
     586                'spost_db_version',
     587                'spost_db_build',
     588                'spost_allowed_level',
     589                'spost_require_email',
     590                'spost_posting_posttype',
     591                'spost_posting_taxonomy',
     592                'spost_posting_status',
     593                'spost_posting_default_user',
     594                'spost_admin_email',
     595                'spost_send_poster_email',
     596                'spost_custom_login_page',
     597                'spost_interval_between_posts',
     598                'spost_log_user_ip',
     599                'spost_login_button_background',
     600                'spost_login_button_text_color',
     601                'spost_register_button_background',
     602                'spost_register_button_text_color',
     603                'spost_or_button_background',
     604                'spost_or_button_text_color',
     605                );
     606    foreach($spostOptions as $spostOption){
     607     //$wpdb->delete( $wpdb -> prefix.'options', array( 'option_name' => $spostOption ) );
     608     delete_option($spostOption);
     609    }   
     610   
     611    deactivate_plugins( plugin_basename( __FILE__ ) ); 
     612    //delete_spost_options();
     613    wp_redirect( admin_url().'plugins.php?#sidebar-posting' ); exit;
     614        }
     615
     616}add_action('admin_init','uninstall_spost_last');
    745617?>
Note: See TracChangeset for help on using the changeset viewer.