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