Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Plugin Name: P&P Filemaker Integration
- * Description: Maneja la sincronización entre Filemaker y el perfil de los usuarios
- * Version: 0.0.1
- * Author: Felipe Castilla
- */
- if ( ! defined( 'ABSPATH' ) ) {
- exit; // Exit if accessed directly.
- }
- // Define constants.
- define( 'FILEMAKER_INTEGRATION_PLUGIN_VERSION', '0.0.1' );
- define( 'FILEMAKER_INTEGRATION_PLUGIN_DIR', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
- // Include the main class.
- require FILEMAKER_INTEGRATION_PLUGIN_DIR . '/FileMaker.php';
- // Main instance of plugin.
- function FileMakerInit() {
- return \PyP\FileMaker\FileMaker::getInstance();
- }
- /*
- * Enqueue Scripts for user-edit page
- */
- function enqueueUserEditScript($hook) {
- if ('user-edit.php' !== $hook) {
- return;
- }
- wp_enqueue_script('pyp-rut-validator', plugin_dir_url(__FILE__) . '/assets/rut.js', null,FILEMAKER_INTEGRATION_PLUGIN_VERSION,true);
- wp_enqueue_script('pyp-user-edit', plugin_dir_url(__FILE__) . '/assets/user-edit.js', array('jquery'),FILEMAKER_INTEGRATION_PLUGIN_VERSION,true);
- }
- add_action('admin_enqueue_scripts', 'enqueueUserEditScript');
- /*
- * On plugin activation schedule our bot
- */
- register_activation_hook( __FILE__, 'scheduleBot' );
- function scheduleBot(){
- $timestamp = wp_next_scheduled( 'pyp_scan_filemaker_files' );
- if( $timestamp == false ){
- wp_schedule_event( time(), 'each_hour', 'pyp_scan_filemaker_files' );
- }
- }
- register_deactivation_hook( __FILE__, 'descheduleBot' );
- function descheduleBot(){
- wp_clear_scheduled_hook( 'pyp_scan_filemaker_files' );
- }
- /*
- * To add a new schedule time interval (each hour)
- */
- add_filter( 'cron_schedules', 'pyp_each_hour_schedule' );
- function pyp_each_hour_schedule( $schedules ) {
- $schedules['each_hour'] = array(
- 'interval' => 60 * MINUTE_IN_SECONDS,
- 'display' => __( 'each hour', 'pyp-filemaker-integration-domain' )
- );
- return $schedules;
- }
- // Global for backwards compatibility.
- $GLOBALS['FileMaker'] = FileMakerInit();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement