admin
9 months ago
pagebuilders
9 months ago
widgets
9 months ago
ajax-functions.php
9 months ago
extras.php
9 months ago
install.php
2 years ago
scripts.php
9 months ago
transient.php
2 years ago
install.php
112 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Install Function |
| 5 | * |
| 6 | * @copyright Copyright (c) 2016, Jeffrey Carandang |
| 7 | * @since 3.0 |
| 8 | */ |
| 9 | // Exit if accessed directly |
| 10 | if (!defined('ABSPATH')) exit; |
| 11 | |
| 12 | //check if free version is activated |
| 13 | if (!function_exists('widgetopts_upgraded')) { |
| 14 | add_action('admin_notices', 'widgetopts_upgraded'); |
| 15 | function widgetopts_upgraded() |
| 16 | { |
| 17 | if (is_plugin_active('widget-options/plugin.php') && is_plugin_active('extended-widget-options/plugin.php')) { ?> |
| 18 | <div class="widgetopts_activated_notice notice-error notice" style="box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);"> |
| 19 | <p> |
| 20 | <?php _e('Please deactivate <strong>Widget Options</strong> Plugin, it may cause issue with the extended plugin version. Thanks!', 'widget-options'); ?> |
| 21 | </p> |
| 22 | </div> |
| 23 | <?php } |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | //add settings link on plugin page |
| 28 | if (!function_exists('widgetopts_filter_plugin_actions')) { |
| 29 | add_action('plugin_action_links_' . plugin_basename(WIDGETOPTS_PLUGIN_FILE), 'widgetopts_filter_plugin_actions'); |
| 30 | function widgetopts_filter_plugin_actions($links) |
| 31 | { |
| 32 | |
| 33 | if (!is_array($links)) { |
| 34 | $links = array(); |
| 35 | } |
| 36 | |
| 37 | $links[] = '<a href="' . esc_url(admin_url('options-general.php?page=widgetopts_plugin_settings')) . '">' . __('Settings', 'widget-options') . '</a>'; |
| 38 | $upgrade_link = apply_filters('widget_options_site_url', trailingslashit(WIDGETOPTS_PLUGIN_WEBSITE) . 'pricing/?utm_source=upgradebtn&utm_medium=plugins&utm_campaign=widgetoptspluginlink'); |
| 39 | $links[] = '<a href="' . esc_url($upgrade_link) . '" target="_blank" style="color: #3db634">' . __('Upgrade', 'widget-options') . '</a>'; |
| 40 | return $links; |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | //register default values |
| 45 | if (!function_exists('widgetopts_register_defaults')) { |
| 46 | register_activation_hook(WIDGETOPTS_PLUGIN_FILE, function () { |
| 47 | add_option('Activated_Plugin', WIDGETOPTS_PLUGIN_FILE); |
| 48 | widgetopts_register_defaults(); |
| 49 | }); |
| 50 | |
| 51 | add_action('admin_init', function () { |
| 52 | if (is_admin() && get_option('Activated_Plugin') == WIDGETOPTS_PLUGIN_FILE) { |
| 53 | delete_option('Activated_Plugin'); |
| 54 | exit(wp_redirect(admin_url('options-general.php?page=widgetopts_plugin_settings'))); |
| 55 | } |
| 56 | }); |
| 57 | |
| 58 | add_action('plugins_loaded', 'widgetopts_register_defaults'); |
| 59 | function widgetopts_register_defaults() |
| 60 | { |
| 61 | if (is_admin()) { |
| 62 | |
| 63 | if (!get_option('widgetopts_installDate')) { |
| 64 | add_option('widgetopts_installDate', date('Y-m-d h:i:s')); |
| 65 | } |
| 66 | |
| 67 | if (!get_option('_widgetopts_default_registered_')) { |
| 68 | //activate free version modules |
| 69 | add_option('widgetopts_tabmodule-visibility', 'activate'); |
| 70 | add_option('widgetopts_tabmodule-devices', 'activate'); |
| 71 | add_option('widgetopts_tabmodule-alignment', 'activate'); |
| 72 | add_option('widgetopts_tabmodule-hide_title', 'activate'); |
| 73 | add_option('widgetopts_tabmodule-classes', 'activate'); |
| 74 | add_option('widgetopts_tabmodule-logic', 'activate'); |
| 75 | add_option('widgetopts_tabmodule-state', 'activate'); |
| 76 | add_option('widgetopts_tabmodule-classic_widgets_screen', 'activate'); |
| 77 | //add free version settings |
| 78 | $defaults = array( |
| 79 | 'visibility' => array( |
| 80 | 'post_type' => '1', |
| 81 | 'taxonomies' => '1', |
| 82 | 'misc' => '1' |
| 83 | ), |
| 84 | 'classes' => array( |
| 85 | 'id' => '1', |
| 86 | 'type' => 'both' |
| 87 | ), |
| 88 | ); |
| 89 | //upgraded settings from previous version |
| 90 | $options = get_option('extwopts_class_settings'); |
| 91 | if (isset($options['class_field'])) { |
| 92 | $defaults['classes']['type'] = $options['class_field']; |
| 93 | } |
| 94 | if (isset($options['classlists'])) { |
| 95 | $defaults['classes']['classlists'] = $options['classlists']; |
| 96 | } |
| 97 | add_option('widgetopts_tabmodule-settings', serialize($defaults)); |
| 98 | add_option('_widgetopts_default_registered_', '1'); |
| 99 | delete_transient('widgetopts_tabs_transient'); //remove transient for settings |
| 100 | delete_option('widgetopts_settings'); |
| 101 | } |
| 102 | |
| 103 | //make sure to delete previous pages cache |
| 104 | if (!get_option('widgetopts_removed_global_pages')) { |
| 105 | delete_option('widgetopts_global_pages'); |
| 106 | add_option('widgetopts_removed_global_pages', 1); |
| 107 | } |
| 108 | } |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | ?> |