Esempio n. 1
0
function ozh_ta_do_page()
{
    global $ozh_ta;
    ?>
    <div class="wrap">
    <?php 
    screen_icon();
    ?>
    <h2>Ozh' Tweet Archiver</h2>
	<style>
	fieldset.ozh_ta_fs {
		border:1px solid #ddd;
		padding:2px 10px;
		padding-bottom:10px;
		margin-bottom:10px;
	}
	
	</style>
	<?php 
    if (ozh_ta_is_debug()) {
        echo "<pre style='border:1px solid;padding:5px 15px;'>";
        var_dump($ozh_ta);
        echo "</pre>";
    }
    if (wp_next_scheduled('ozh_ta_cron_import') && !ozh_ta_is_manually_archiving()) {
        ozh_ta_do_page_scheduled();
    }
    if (ozh_ta_is_configured()) {
        ozh_ta_do_page_manual();
    }
    // Option page when not doing operation
    if (!isset($_GET['action']) or $_GET['action'] != 'import_all') {
        ?>
	    <form action="options.php" method="post">
		<?php 
        settings_fields('ozh_ta');
        ?>
		<?php 
        do_settings_sections('ozh_ta');
        ?>
		<script type="text/javascript">
		(function($){
			$('.toggler').change(function(){
				var id = $(this).attr('id');
				var val = $(this).val();
				$('.toggle_'+id).hide();
				$('#toggle_'+id+'_'+val).show();
				pulse('#toggle_'+id+'_'+val );
			});
			
			var maxw = 0;
			$('select').each(function(i,e){
				var w = jQuery(this).css('width').replace('px', '');
				maxw = Math.max( maxw, w );
			}).css('width', maxw+'px');
			
			$('#link_hashtags').change(function(){
				if( $(this).val() == 'local' ) {
					pulse( $('#add_hash_as_tags').val('yes').change() );
				}
			});
			
			$('#add_hash_as_tags').change(function(){
				if( $(this).val() == 'no' && $('#link_hashtags').val() == 'local' ) {
					pulse( $('#link_hashtags').val('twitter').change() );
				}
			});
			
			function pulse( el ){
			var bg = $(el).css('backgroundColor');
			$(el).animate({backgroundColor: '#ff4'}, 500, function(){
				$(el).animate({backgroundColor: bg}, 500, function(){
					$(el).css('backgroundColor', bg);
				});
			});
			}
		
		})(jQuery);
		</script>
        <?php 
        submit_button();
        submit_button('Reset all settings', 'delete', 'delete_btn');
        ?>
        <script>
        (function($){
        $('#delete_btn').click( function() {
            if (!confirm('Really reset everything? No undo!')) {
                return false;
            }
        });
        })(jQuery);
        </script>
	    </form>
	<?php 
    }
    ?>

	</div>
    <?php 
}
Esempio n. 2
0
function ozh_ta_validate_options($input)
{
    global $ozh_ta;
    // Screw validation. Just don't be an idiot.
    // Reset if applicable
    if (isset($_POST['delete_btn'])) {
        $input = array();
        ozh_ta_schedule_next(0);
    } else {
        // don't lose stuff that are not "settings" submitted in the plugin page
        $input = array_merge($ozh_ta, $input);
        // Consumer key & secret defined? Get an OAuth token
        if (isset($input['cons_key']) && isset($input['cons_secret']) && !ozh_ta_is_manually_archiving()) {
            $input['access_token'] = ozh_ta_get_token($input['cons_key'], $input['cons_secret']);
        }
    }
    return $input;
}