Monday, August 29, 2016

CSS OPTIONS PLUGIN


NOTES:


version 1.0 under development.



bugs:
1. Crashes media library searching for solution.
2. the css files don't translate to other themes. keep the css files universal.
3. upload pictures of the CSS OPTION along with.







<?php
/**
 * Plugin Name: Image Loop - Custom - Fulcrum Creative.
 * Plugin URI: http://www.fulcrum-creative.com
 * Description: This is a customizable Product Loop that handles CSS -Fulcrum Creative.com. All Rights Reserved.
 * Version: 1.0.0
 * Author: Shaheryar Afzal aka Cliff
 * Author URI: http://www.fulcrum-creative.com
 * License: Copyright.


  */

 ?>







<?php



register_activation_hook( __FILE__, 'set_up_options' );



?>



<?php

add_action( 'woocommerce_after_shop_loop_item_title', 'FC_woocommerce_product_excerpt', 10, 2);





// FUNCTIONS TO ADD EXCERPTS to the PRODUCT. Aka. DESCRIPTIONS.




function new_excerpt_length($length) {
    return 20;
}
add_filter('excerpt_length', 'new_excerpt_length');

?>

<?php

// ADD THE OPTIONS PAGE IN the SETTINGS MENU HEADER.


add_action('admin_menu', 'plugin_admin_add_page');


function plugin_admin_add_page() {


add_options_page('Custom Plugin Page', 'Product Image Settings', 'manage_options', 'plugin', 'plugin_options_page');
}


?>


<?php

// REGISTER SETTINGS

function register_mysettings() {

register_setting('css_options_value', 255);

  register_setting( 'optionselect', 'option1' );
  register_setting( 'optionselect', 'option2' );
  register_setting( 'optionselect', 'option3' );
 
  register_setting( 'optionselect', 'option1b' );
  register_setting( 'optionselect', 'option2b' );
  register_setting( 'optionselect', 'option3b' );


}

add_action ('register_settings', 'register_mysettings');



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

?>
<?php // display the admin options page
function plugin_options_page() {



?>
<div>
<h2>Select a Style - CSS OPTIONS file!</h2>

Select the style of box you would like to apply to your product images




 <?php

?>



<form name="product_options" method="post">

<body>

<p>
  <input type="radio" name="optionselect" value="option1"  checked="checked" /> Option 1<br>
  <p>
 
  <input type="radio" name="optionselect" value="option1b"> Option 1 - b<br>
  <p>
  <input type="radio" name="optionselect" value="option2"> Option 2<br>
  <p>
  <input type="radio" name="optionselect" value="option2b"> Option 2 - b<br>
  <p>
  <input type="radio" name="optionselect" value="option3"> Option 3<br />
  <p>
  <input type="radio" name="optionselect" value="option3b"> Option 3 - b<br>
 

<input name="Submit" type="submit" value="Save Changes" />
</form>

<?php
?>
<?php









?>
The option you the user, developer selected was:
<?php // $options_select = 'option1'; ?>
<p>
<?php



?>
<?php


 $outputcheck = get_option ('css_options_value', $defaults);



  echo $outputcheck;
}

?>
<?php

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////


//    the following function chooses the option file for the CSS OPTION you      wish to use. DIFFERENT CSS files with the appropriate option must be      given as options in the form created above.


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////




function scripts_css(){

echo $option_select;
   $dir = plugin_dir_url( __FILE__);




 if(isset($_POST['optionselect'])){
 
 $option_select = $_POST['optionselect'];

 
}

if (!empty($_POST['optionselect'])) {

$update_ops = ($dir .'css/'  . $option_select . '.css');
get_option('css_options_value');




update_option('css_options_value', $update_ops);

// update_option('css_options_value', $default_ops);




 echo $update_ops;


wp_enqueue_style('css_options_value');



}

  else{

$the_old_value = get_option('css_options_value');

// $the_old_value = ('trying to put in a default value');
update_option('css_options_value', $the_old_value);

wp_enqueue_style( 'css_options_value', $the_old_value);








// add_option('css_options_value', $default_ops);
//wp_enqueue_style( 'css_options_value', $default_ops);










 





// wp_parse_args( get_option( 'css_options_value', $defaults));

 
}
 }



//}

add_action( 'script_enqueue_action', 'scripts_css' );
do_action ('script_enqueue_action');














 
 
 

?>










</div>




<?php


?>