1

I am currently working on a simple plugin. Activating my plugin works fine. However, I can't activate any other plugin as long as mine is active. Also, the edit links won't work.

Any help with this would be great! Below is the code for the main plugin file sponsoren.php

<?php  
/* 
Plugin Name: Sponsoren
Plugin URI: 
Version: 
Author: 
Description: 
*/  

// Enqueue Scripts
add_action( 'admin_enqueue_scripts', 'sponsoren_admin' );
add_action('admin_menu', 'sponsoren_custom_menu_page');
add_action( 'wp_enqueue_scripts', 'sponsoren_frontend' );

function sponsoren_custom_menu_page() {
   $page = add_menu_page( 'Sponsoren', 'Sponsoren', 'manage_options', 
       'sponsoren/sponsoren-admin.php', '', plugins_url( 'sponsoren/images/icon.png' ), 33 );
}

function sponsoren_admin() {
    wp_enqueue_style( 'sponsoren-admin-style', plugins_url('/stylesheet.css', __FILE__) );
    wp_enqueue_script( 'sponsoren-admin-script', plugins_url('/script.js', __FILE__) );
}

function sponsoren_frontend() {
    wp_enqueue_style( 'sponsoren-frontend-style', plugins_url('/sponsoren.css', __FILE__) );
    wp_enqueue_script( 'sponsoren-frontend-script', plugins_url('/sponsoren.js', __FILE__), array( 'jquery' ) );
}

// Create database table upon activation
function jal_install() {
   global $wpdb;

   $table_name = $wpdb->prefix . "sponsoren";

   $sql = "CREATE TABLE $table_name (
   id int NOT NULL AUTO_INCREMENT,
   name tinytext,
   bild tinytext,
   url tinytext,
   PRIMARY KEY id (id)
    );";

}

register_activation_hook( __FILE__, 'jal_install' );

// Ajax action used in sponsoren-admin.php
add_action('wp_ajax_sponsor_delete', 'sponsor_del');
function sponsor_del() {
    global $wpdb;
    $wpdb->delete( $wpdb->prefix.'sponsoren', array( 'id' => $_POST['deleteid'] ) );
    die();
}

// Widget
function widget_sponsoren_frontend($args=array(), $params=array()) {

    $title = get_option('widget_sponsoren_title');

    echo $before_widget;
    echo $before_title . $title . $after_title;
    // some more widget output

    echo $after_widget; 
}

wp_register_sidebar_widget('widget_sponsoren','Unsere Sponsoren', 'widget_sponsoren_frontend');

// Widget Options
wp_register_widget_control(
    'widget_sponsoren',     // id
    'widget_sponsoren',     // name
    'widget_sponsoren_control'  // callback function
);

function widget_sponsoren_control($args=array(), $params=array()) {

    if (isset($_POST['submitted'])) {
        update_option('widget_sponsoren_title', $_POST['widgettitle']);
    }

    $widgettitle = get_option('widget_sponsoren_title');
    ?>

    Widget Title:<br />
    <input type="text" class="widefat" name="widgettitle" value="<?php echo stripslashes($widgettitle); ?>" />

    <input type="hidden" name="submitted" value="0" />
    <?php
}
0

1 Answer 1

1

You should first make sure that you don't get any JavaScript errors. Plugin activations and edit buttons are using JavaScript and if your code has issues, it might break some portions of the website. Use Chrome Inspect to check it for JS errors.

1
  • Oh my god. So simple. I used a jQuery-selector 'a.edit' within my plugin... This also selected the activation and edit links on the plugin page. Thank you so much!
    – eevaa
    Nov 28, 2013 at 19:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.