Пример #1
0
require plugin_dir_path(__FILE__) . 'includes/class-plugin-name.php';
/**
 * Begins execution of the plugin.
 *
 * Since everything within the plugin is registered via hooks,
 * then kicking off the plugin from this point in the file does
 * not affect the page life cycle.
 *
 * @since    1.0.0
 */
function run_plugin_name()
{
    $plugin = new Plugin_Name();
    $plugin->run();
}
run_plugin_name();
/*----------------------------------------------------------------------------------------------------*/
class wp_my_plugin extends WP_Widget
{
    // constructor
    function wp_my_plugin()
    {
        parent::WP_Widget(false, $name = __('Material Card', 'wp_widget_plugin'));
    }
    // widget form creation
    function form($instance)
    {
        // Check values
        if ($instance) {
            $title = esc_attr($instance['title']);
            $text = esc_attr($instance['text']);
function myplugin_update_db_check()
{
    global $kz_db_version, $wpdb, $table_name;
    $current_version = get_site_option('kz_db_version');
    //update_site_option('kz_db_version', '1.0.4'); exit;
    // var_dump($table_name); exit;
    if (get_site_option('kz_db_version') != $kz_db_version) {
        Custom_Widget_Area_Activator::activate();
        if (!!$current_version && $current_version < '1.1.0') {
            $row = $wpdb->get_results("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = '{$table_name}' AND column_name = 'cwa_type'");
            if (empty($row)) {
                $x = $wpdb->query("ALTER TABLE {$table_name} ADD cwa_type varchar (10) ");
                $updaterow = $wpdb->get_results("SELECT id FROM {$table_name}");
                foreach ($updaterow as $data) {
                    # code...
                    $up = $wpdb->update($table_name, array('cwa_type' => 'widget'), array('id' => $data->id));
                }
            }
        }
    }
    run_plugin_name();
}