简体   繁体   English

我的 wordpress 插件不是从 zip 文件安装的

[英]My wordpress plugin isn't installing from a zip file

I created a WP plugin, with minimal PHP code - it's almost JS.我用最少的 PHP 代码创建了一个 WP 插件——它几乎是 JS。 When I upload files manually to the WP plugins directory, it works.当我手动将文件上传到 WP 插件目录时,它起作用了。

But when I'm trying to zip the plugin and install it from a zip file, it doesn't work.但是当我尝试 zip 插件并从 zip 文件安装它时,它不起作用。

The PHP code itself is minimal. PHP 代码本身是最小的。

I created a header with minimal requirements and some code to return html and to registre JS and CSS files.我创建了一个具有最低要求的 header 和一些代码来返回 html 并注册 JS 和 CSS 文件。

There are other files too: image files, JS files (2 of them)还有其他文件:图像文件、JS 文件(其中 2 个)

When I'm trying to install them, I get a message: The link you followed has expired.当我尝试安装它们时,我收到一条消息:您点击的链接已过期。

Please try again.请再试一遍。

I did everything according to tutorials, checked with several of them, and I have no Idea what I'm doing wrong.我根据教程做了所有事情,检查了其中的几个,但我不知道我做错了什么。

Here's my code:这是我的代码:

<?php
/**
 * Plugin Name: Plugin name
 * Description: Plugin description
 * Version: 1.0.1
 * Author: Author
 */



function dare2care( $atts, $content, $tag ){

    wp_register_style( 'dare2care', 'https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css' );

    wp_enqueue_style('dare2care');

    wp_enqueue_script('dare2care-quiz', plugins_url( 'dare2care-quiz.js', __FILE__ ), in_footer:true);

    $image_base_url = plugins_url( 'images/', __FILE__ );

 $content = '


    <div id="quiz" class="container">
        ... truncated...
    </div>

';

return $content;

};

add_shortcode('d2c', 'dare2care');

function register_shortcodes(){
    add_shortcode('d2c', 'dare2care');
};

add_action( 'init', 'register_shortcodes');

?>

You have to add this to your theme functions.php您必须将其添加到您的主题functions.php中。php

@ini_set( 'upload_max_size' , '120M' );
@ini_set( 'post_max_size', '120M');
@ini_set( 'max_execution_time', '300' );

It's a known issue that needs a deeper approach to avoid.这是一个已知问题,需要更深入的方法来避免。 I don't know if I can analyze the whole situation assuming to stackoverflow rules.我不知道是否可以根据 stackoverflow 规则分析整个情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM