Your IP : 216.73.216.186


Current Path : /home/pressec/www/presselib/wp-content/plugins/presselib-blocks/
Upload File :
Current File : /home/pressec/www/presselib/wp-content/plugins/presselib-blocks/presselib-blocks.php

<?php
/*
Plugin Name: Presselib Blocks
Plugin URI: http://frederic-malaterre.com/wordpress/plugins
Description: Create blocks and define the display. Created for http://presselib.com - Créez des blocks et definissez leurs dates d'affichage. 
Version: 0.4.0
Author: Fred Malaterre
Author URI: http://frederic-malaterre.com
License: GPLv2
*/

/*  Copyright 2015  Fred Malaterre  (email : frederic@malaterre.me)

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

register_activation_hook( __FILE__, 'frm_presselibBlocks_install' );

function frm_presselibBlocks_install() {
    if ( version_compare( get_bloginfo( 'version' ), '4.3', '<' ) ) {
        deactivate_plugins( basename( __FILE__ ) ); // Deactivate our plugin
    }
	update_option( 'fm_presselibBlocks_options',array() );
}

register_deactivation_hook( __FILE__, 'frm_presselibBlocks_deactivate' );

function frm_presselibBlocks_deactivate() {
	//
}



add_action( 'admin_init', 'fm_presselibBlocks_settings' ); // déclaration des options
add_action( 'admin_menu', 'fm_presselibBlocks_menu' );



function fm_presselibBlocks_settings( )
{
	register_setting( 'Presselib_maintenance', 'maintenance_actif', array('type'=>'boolean') ); 
	register_setting( 'Presselib_maintenance', 'maintenance_titre', array('type'=>'string', 'sanitize_callback'=>'stopinjection') ); 
	register_setting( 'Presselib_maintenance', 'maintenance_content', array('type'=>'string', 'sanitize_callback'=>'stopinjection') ); 
	
	//register_setting( 'Presselib_jeux', 'jeux_actif' );
	register_setting( 'Presselib_jeux', 'date_debut_jeu', array('type'=>'string', 'sanitize_callback'=>'stopinjection') );
	register_setting( 'Presselib_jeux', 'date_fin_jeu', array('type'=>'string', 'sanitize_callback'=>'stopinjection') );
}

function stopinjection( $input = NULL ) 
{
	if( strstr( $input, '<' )) {
		return htmlentities( $input );
	} else {
		return $input;
	}
}

function fm_presselibBlocks_menu( )
{
	add_menu_page(
		'Blocks de Presselib', // le titre de la page
		'Affichage des blocks',            // le nom de la page dans le menu d'admin
		'administrator',        // le rôle d'utilisateur requis pour voir cette page
		'fm_block',        // un identifiant unique de la page
		'fm_presselibBlock_displayAdminPage',   // le nom d'une fonction qui affichera la page
		'dashicons-grid-view',
		'64'
	);
}

function fm_presselibBlock_displayAdminPage( )
{
	// affichage de la page d'admin
?>
	<h2>Les blocks Presselib</h2>
	
	<!-- MAINTENANCE -->
	<div id="wpcom-stats-meta-box-container" class="metabox-holder">
		<div class="postbox-container" style="width: 45%;  margin-right:10px">
			<div id="normal-sortables" class="meta-box-sortables ui-sortable">
				<div id="referrers" class="postbox">
					<form method="post" action="options.php">
						<?php
							settings_fields( 'Presselib_maintenance' );
						?>
						<h3 class="hndle ui-sortable-handle">Block maintenance</h3>
						<div class="inside">
							<table class="form-table">
								<tr valign="top">
									<th scope="row"><label for="maintenance_actif">Activer</label></th>
									<td><input type="checkbox"  id="maintenance_actif" name="maintenance_actif" class="medium-text ltr" <?php if(get_option( 'maintenance_actif' )) echo "checked"; ?> value="true" ></td>
								</tr>
								<tr valign="top">
									<th scope="row"><label for="maintenance_titre">Titre</label></th>
									<td><input type="text"  id="maintenance_titre" name="maintenance_titre" class="medium-text ltr" value="<?php echo get_option( 'maintenance_titre' ); ?>" /></td>
								</tr>
								<tr valign="top">
									<th scope="row"><label for="maintenance_content">Message</label></th>
									<td><?php $content = get_option( 'maintenance_content' );;
											$editor_id = 'maintenance_content';
											$settings=array("editor_height"=>150,);
											wp_editor( $content, $editor_id, $settings ); ?>
									</tr>
							</table>
						</div>
						<div id="major-publishing-actions">
							<div id="publishing-action">
								<input type="submit" class="button-primary" value="Mettre à jour" />
							</div>
							<div class="clear"></div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
	
	<!-- JEUX -->
	<div id="wpcom-stats-meta-box-container-2" class="metabox-holder">
		<div class="postbox-container" style="width: 45%;  margin-right:10px">
			<div id="normal-sortables-2" class="meta-box-sortables ui-sortable">
				<div id="referrers-2" class="postbox">
					<form method="post" action="options.php">
						<?php
							settings_fields( 'Presselib_jeux' );
						?>
						<h3 class="hndle ui-sortable-handle">Block Jeux</h3>
						<div class="inside">
							<table class="form-table">
								<tr valign="top">
										<th scope="row"><label for="date_debut_jeu">Date de début</label></th>
										<td><input type="date"  id="date_debut_jeu" name="date_debut_jeu" class="medium-text ltr" value="<?php echo get_option( 'date_debut_jeu' ); ?>" /></td>
								</tr>
								<tr valign="top">
									<th scope="row"><label for="date_fin_jeu">Date de fin</label></th>
									<td><input type="date"  id="date_fin_jeu" name="date_fin_jeu" class="medium-text ltr" value="<?php echo get_option( 'date_fin_jeu' ); ?>" /></td>
								</tr>
							</table>
						</div>
						<div id="major-publishing-actions">
							<div id="publishing-action-2">
								<input type="submit" class="button-primary" value="Mettre à jour" />
							</div>
							<div class="clear"></div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
	
<?php
}












?>