| 1 |
<?php |
| 2 |
/* |
| 3 |
Plugin Name: Themify Event Post |
| 4 |
Plugin URI: https://themify.me/event-post |
| 5 |
Version: 1.3.3 |
| 6 |
Author: Themify |
| 7 |
Author URI: https://themify.me |
| 8 |
Description: This plugin will add an Event post type. A simple way to display events on your site. |
| 9 |
Text Domain: themify-event-post |
| 10 |
Domain Path: /languages |
| 11 |
Requires PHP: 7.2 |
| 12 |
Compatibility: 7.0.0 |
| 13 |
/* |
| 14 |
* This program is free software; you can redistribute it and/or modify |
| 15 |
* it under the terms of the GNU General Public License as published by |
| 16 |
* the Free Software Foundation; either version 2 of the License, or |
| 17 |
* (at your option) any later version. |
| 18 |
* |
| 19 |
* This program is distributed in the hope that it will be useful, |
| 20 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 |
* GNU General Public License for more details. |
| 23 |
* |
| 24 |
* You should have received a copy of the GNU General Public License |
| 25 |
* along with this program; if not, write to the Free Software |
| 26 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
| 27 |
* MA 02110-1301, USA. |
| 28 |
* |
| 29 |
*/ |
| 30 |
|
| 31 |
defined( 'ABSPATH' ) or die; |
| 32 |
|
| 33 |
function themify_event_post_setup() { |
| 34 |
// Check if Themify theme has registered event post type |
| 35 |
if(function_exists('themify_post_types')){ |
| 36 |
if(in_array('event',themify_post_types())){ |
| 37 |
add_action( 'admin_init', 'themify_event_deactivate' ); |
| 38 |
add_action( 'admin_notices', 'themify_event_admin_notice' ); |
| 39 |
return false; |
| 40 |
} |
| 41 |
} |
| 42 |
include plugin_dir_path( __FILE__ ) . 'includes/system.php'; |
| 43 |
|
| 44 |
Themify_Event_Post::get_instance( array( |
| 45 |
'url' => trailingslashit( plugin_dir_url( __FILE__ ) ), |
| 46 |
'dir' => trailingslashit( plugin_dir_path( __FILE__ ) ), |
| 47 |
'version' => '1.3.3' |
| 48 |
) ); |
| 49 |
} |
| 50 |
add_action( 'after_setup_theme', 'themify_event_post_setup' ); |
| 51 |
add_filter( 'plugin_row_meta', 'themify_event_post_plugin_meta', 10, 2 ); |
| 52 |
add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'themify_event_post_action_links' ); |
| 53 |
|
| 54 |
function themify_event_post_plugin_meta( $links, $file ) { |
| 55 |
if ( plugin_basename( __FILE__ ) === $file ) { |
| 56 |
$row_meta = array( |
| 57 |
'changelogs' => '<a href="' . esc_url( 'https://themify.org/changelogs/' ) . basename( dirname( $file ) ) .'.txt" target="_blank" aria-label="' . esc_attr__( 'Plugin Changelogs', 'themify-event-post' ) . '">' . esc_html__( 'View Changelogs', 'themify-event-post' ) . '</a>' |
| 58 |
); |
| 59 |
|
| 60 |
return array_merge( $links, $row_meta ); |
| 61 |
} |
| 62 |
return (array) $links; |
| 63 |
} |
| 64 |
function themify_event_post_action_links( $links ) { |
| 65 |
if ( is_plugin_active( 'themify-updater/themify-updater.php' ) ) { |
| 66 |
$tlinks = array( |
| 67 |
'<a href="' . admin_url( 'index.php?page=themify-license' ) . '">'.__('Themify License', 'themify-event-post') .'</a>', |
| 68 |
); |
| 69 |
} else { |
| 70 |
$tlinks = array( |
| 71 |
'<a href="' . esc_url('https://themify.me/docs/themify-updater-documentation') . '">'. __('Themify Updater', 'themify-event-post') .'</a>', |
| 72 |
); |
| 73 |
} |
| 74 |
return array_merge( $links, $tlinks ); |
| 75 |
} |
| 76 |
|
| 77 |
/** |
| 78 |
* Plugin activation hook |
| 79 |
* Flush rewrite rules after custom post type has been registered |
| 80 |
*/ |
| 81 |
function themify_event_post_activation() { |
| 82 |
if(false === themify_event_post_setup()){ |
| 83 |
return false; |
| 84 |
} |
| 85 |
include trailingslashit( plugin_dir_path( __FILE__ ) ) . 'includes/post-type.php'; |
| 86 |
themify_event_post_register_post_type(); |
| 87 |
flush_rewrite_rules(); |
| 88 |
} |
| 89 |
register_activation_hook( __FILE__, 'themify_event_post_activation' ); |
| 90 |
|
| 91 |
|
| 92 |
function themify_event_deactivate() { |
| 93 |
deactivate_plugins( plugin_basename( __FILE__ ) ); |
| 94 |
} |
| 95 |
|
| 96 |
function themify_event_admin_notice() { |
| 97 |
echo sprintf("<div class='updated'><p>%s</p></div>",__('Your Themify theme already has Event post type, don\'t need to activate the Themify Event Post plugin.','themify-event-post')); |
| 98 |
if ( isset( $_GET['activate'] ) ){ |
| 99 |
unset( $_GET['activate'] ); |
| 100 |
} |
| 101 |
} |
| 102 |
|