This repository has been archived by the owner on Mar 11, 2024. It is now read-only.
forked from richardsweeney/instagram
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shipyard-instagram.php
executable file
·79 lines (64 loc) · 2.17 KB
/
shipyard-instagram.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
/*
Plugin Name: Shipyard Instagram
Version: 0.1
Description: Instagram Plugin for Barncancerfonden
Author: The Shipyard crew
Author URI: https://theshipyard.se
Text Domain: shipyard-instagram
Domain Path: /languages
*/
// load translations
load_plugin_textdomain( 'shipyard-instagram', false, dirname( plugin_basename(__FILE__) ) . '/languages/' );
/**
* Register autoloader.
*/
function shipyard_instagram_autoloader( $classname ) {
$classname = explode( '\\', $classname );
$classfile = sprintf( '%sincludes/class-%s.php',
plugin_dir_path( __FILE__ ),
str_replace( '_', '-', strtolower( end( $classname ) ) )
);
if ( file_exists( $classfile ) ) {
include_once( $classfile );
}
}
spl_autoload_register( 'shipyard_instagram_autoloader' );
/**
* Register a cron hook every fifteen minutes.
*
* @param array $schedules Array of cron schedules.
*
* @return array Modified array of cron schedules.
*/
function shipyard_instagram_add_cron_schedules( $schedules ) {
$schedules['fifteen_minutes'] = array(
'interval' => MINUTE_IN_SECONDS * 15,
'display' => __( 'Every Fifteen Minutes', 'shipyard-instagram' ),
);
return $schedules;
}
add_filter( 'cron_schedules', 'shipyard_instagram_add_cron_schedules' );
/**
* Activate the cron hooks on plugin activation.
*/
function shipyard_instagram_activation() {
wp_schedule_event( current_time( 'timestamp' ), 'fifteen_minutes', 'update_instagram_feed' );
wp_schedule_event( current_time( 'timestamp' ), 'daily', 'delete_old_instragram_posts' );
}
register_activation_hook( __FILE__, 'shipyard_instagram_activation' );
/**
* Remove the cron hooks on plugin deletion.
*/
function shipyard_instagram_deactivation() {
wp_clear_scheduled_hook( 'update_instagram_feed' );
wp_clear_scheduled_hook( 'delete_old_instragram_posts' );
}
register_deactivation_hook( __FILE__, 'shipyard_instagram_deactivation' );
Shipyard_Instagram_Post_Type::get();
Shipyard_Instagram_Import_Images::get();
Shipyard_Instagram_Options_Page::get();
// API
function shipyard_instagram_render_images( $num_images = 9 ) {
Shipyard_Instagram_Display_Images::get()->render_images( $num_images );
}