Skip to content

Commit

Permalink
Programs multi-filter, Google Analytics off-site tracking, Form fix #86
Browse files Browse the repository at this point in the history
  • Loading branch information
kimpenguin authored Oct 30, 2018
2 parents f885c66 + 6b9f6db commit 765f9e5
Show file tree
Hide file tree
Showing 84 changed files with 47,322 additions and 12,425 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"wpackagist-plugin/limit-login-attempts-reloaded": "2.7.1",
"filp/whoops": "^2.1",
"whoops/soap": "^1.0",
"nyco/wp-config": "^0.0.5"
"nyco/wp-config": "^0.0.5",
"wpackagist-plugin/acf-to-rest-api": "3.1.0"
}
}
74 changes: 47 additions & 27 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions wp-content/mu-plugins/config/development.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@
*/

// Disable plugins
// require_once ABSPATH . 'wp-admin/includes/plugin.php';
// deactivate_plugins('plugin/plugin.php');
require_once ABSPATH . 'wp-admin/includes/plugin.php';
deactivate_plugins('google-authenticator/google-authenticator.php');

// Discourage search engines
// @url https://codex.wordpress.org/Option_Reference#Privacy
update_option('blog_public', 0);
10 changes: 7 additions & 3 deletions wp-content/mu-plugins/gu-post-types.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ function create_post_types() {
'public' => true,
'menu_position' => 21,
'menu_icon' => 'dashicons-carrot',
'show_in_rest' => true,
'supports' => array( 'title', 'excerpt' ),
'has_archive' => true,
'rewrite' => array(
Expand Down Expand Up @@ -178,7 +179,8 @@ function create_taxonomies() {
array(
'label' => __( 'Event Location' ),
'hierarchical' => true,
'rewrite' => false
'rewrite' => false,
'show_in_rest' => true
)
);

Expand All @@ -188,7 +190,8 @@ function create_taxonomies() {
array(
'label' => __( 'Age Groups' ),
'hierarchical' => true,
'rewrite' => false
'rewrite' => false,
'show_in_rest' => true
)
);

Expand All @@ -197,7 +200,8 @@ function create_taxonomies() {
array('program'),
array(
'label' => __( 'Program Categories' ),
'hierarchical' => true
'hierarchical' => true,
'show_in_rest' => true
)
);

Expand Down
3 changes: 2 additions & 1 deletion wp-content/mu-plugins/ms-topics.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ function ms_topics_create() {
'slug' => 'other-category',
'with_front' => false
),
'hierarchical' => true
'hierarchical' => true,
'show_in_rest' => true,
)
);
}
Expand Down
136 changes: 136 additions & 0 deletions wp-content/plugins/acf-to-rest-api/class-acf-to-rest-api.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
<?php
/**
* Plugin Name: ACF to REST API
* Description: Exposes Advanced Custom Fields Endpoints in the WordPress REST API
* Author: Aires Gonçalves
* Author URI: http://github.com/airesvsg
* Version: 3.1.0
* Plugin URI: http://github.com/airesvsg/acf-to-rest-api
*/

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

if ( ! class_exists( 'ACF_To_REST_API' ) ) {

class ACF_To_REST_API {

const VERSION = '3.1.0';

private static $old_request_version = 2;
private static $default_request_version = 3;
private static $request_version;

private static $instance = null;

public static function init() {
self::includes();
self::hooks();
}

protected static function instance() {
if ( is_null( self::$instance ) ) {
$class = 'ACF_To_REST_API_V' . self::handle_request_version();
if ( class_exists( $class ) ) {
self::$instance = new $class;
}
}
return self::$instance;
}

private static function includes() {
if ( self::$old_request_version == self::handle_request_version() ) {
require_once dirname( __FILE__ ) . '/legacy/v2/class-acf-to-rest-api-v2.php';
} else {
require_once dirname( __FILE__ ) . '/v3/class-acf-to-rest-api-v3.php';
}

if ( self::is_plugin_active( 'all' ) ) {
if ( is_admin() ) {
require_once dirname( __FILE__ ) . '/shared/lib/class-acf-to-rest-api-settings.php';
}
self::instance()->includes();
}
}

public static function handle_request_version() {
if ( is_null( self::$request_version ) ) {
if ( defined( 'ACF_TO_REST_API_REQUEST_VERSION' ) ) {
self::$request_version = (int) ACF_TO_REST_API_REQUEST_VERSION;
} else {
self::$request_version = (int) get_option( 'acf_to_rest_api_request_version', self::$default_request_version );
}
}
return self::$request_version;
}

private static function hooks() {
add_action( 'init', array( __CLASS__, 'load_plugin_textdomain' ) );

if ( self::is_plugin_active( 'all' ) ) {
add_action( 'rest_api_init', array( __CLASS__, 'create_rest_routes' ), 10 );
if ( self::$default_request_version == self::handle_request_version() ) {
ACF_To_REST_API_ACF_Field_Settings::hooks();
}
} else {
add_action( 'admin_notices', array( __CLASS__, 'missing_notice' ) );
}

}

public static function load_plugin_textdomain() {
$locale = apply_filters( 'plugin_locale', get_locale(), 'acf-to-rest-api' );
load_textdomain( 'acf-to-rest-api', untrailingslashit( plugin_dir_path( __FILE__ ) ) . '/languages/' . $locale . '.mo' );
}

public static function create_rest_routes() {
self::instance()->create_rest_routes();
}

public static function is_plugin_active( $plugin ) {
if ( 'rest-api' == $plugin ) {
return class_exists( 'WP_REST_Controller' );
} elseif ( 'acf' == $plugin ) {
return class_exists( 'acf' );
} elseif ( 'all' == $plugin ) {
return class_exists( 'WP_REST_Controller' ) && class_exists( 'acf' );
}

return false;
}

public static function is_plugin_installed( $plugin ) {
if ( ! function_exists( 'get_plugins' ) ) {
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
}

$paths = false;
if ( 'rest-api' == $plugin ) {
$paths = array( 'rest-api/plugin.php' );
} elseif ( 'acf' == $plugin ) {
$paths = array( 'advanced-custom-fields-pro/acf.php', 'acf-pro/acf.php', 'advanced-custom-fields/acf.php' );
}

if ( $paths ) {
$plugins = get_plugins();
if ( is_array( $plugins ) && count( $plugins ) > 0 ) {
foreach ( $paths as $path ) {
if ( isset( $plugins[ $path ] ) && ! empty( $plugins[ $path ] ) ) {
return $path;
}
}
}
}

return false;
}

public static function missing_notice() {
self::instance()->missing_notice();
}
}

add_action( 'plugins_loaded', array( 'ACF_To_REST_API', 'init' ) );

}
Loading

0 comments on commit 765f9e5

Please sign in to comment.