Skip to content

Commit

Permalink
✨ 优化依赖,兼容PHP7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Licoy committed Apr 24, 2023
1 parent 06ddf1b commit 7883710
Show file tree
Hide file tree
Showing 37 changed files with 585 additions and 4,372 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<img src="https://img.shields.io/badge/WordPress-V5.0+-0099CC.svg?logo=wordpress" alt="WordPress-Version">
</a>
<a href="https://github.com/Licoy/wordpress-theme-puock">
<img src="https://img.shields.io/badge/PHP-V8.0.2+-666699.svg?logo=php" alt="PHP-Version">
<img src="https://img.shields.io/badge/PHP-V7.4+-666699.svg?logo=php" alt="PHP-Version">
</a>
<a href="https://gitee.com/licoy/wordpress-theme-puock">
<img src="https://img.shields.io/badge/Gitee-码云-CC3333.svg?logo=gitee" alt="Gitee">
Expand Down Expand Up @@ -58,9 +58,9 @@

### 环境要求

- WordPress `5.0+`
- PHP `8.0.2+`
- MySQL `5.6+`
- WordPress `>=5.0`
- PHP `>=7.4`
- MySQL `>=5.6`

## 主题特性

Expand Down
50 changes: 27 additions & 23 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
{
"name": "licoy/wordpress-theme-puock",
"description": "A high-value adaptive theme based on WordPress, supports day and night modes, no refresh loading, etc.",
"type": "project",
"license": "GPL V3",
"autoload": {
"psr-4": {
"Puock\\Theme\\": "inc/"
}
},
"authors": [
{
"name": "Licoy"
}
],
"require": {
"yurunsoft/yurun-oauth-login": "~3.0",
"zoujingli/ip2region": "^2.0",
"orhanerday/open-ai": "^4.7",
"gioni06/gpt3-tokenizer": "^1.2"
"name": "licoy/wordpress-theme-puock",
"description": "A high-value adaptive theme based on WordPress, supports day and night modes, no refresh loading, etc.",
"type": "project",
"license": "GPL V3",
"autoload": {
"psr-4": {
"Puock\\Theme\\": "inc/"
}
},
"authors": [
{
"name": "Licoy"
}
],
"require": {
"yurunsoft/yurun-oauth-login": "~3.0",
"zoujingli/ip2region": "^2.0",
"orhanerday/open-ai": "^4.7",
"rahul900day/gpt-3-encoder": "^1.1"
},
"config": {
"platform-check": false,
"allow-plugins": {
"php-http/discovery": false
},
"config": {
"allow-plugins": {
"php-http/discovery": false
}
"platform": {
"php": "7.4"
}
}
}
120 changes: 66 additions & 54 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 5 additions & 8 deletions inc/ajax/ai.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
<?php


use Gioni06\Gpt3Tokenizer\Gpt3Tokenizer;
use Gioni06\Gpt3Tokenizer\Gpt3TokenizerConfig;
use Orhanerday\OpenAi\OpenAi;
use Rahul900day\Gpt3Encoder\Encoder;

function pk_ajax_openai_token_len($text): int
function pk_openai_token_len($text): int
{
$tokenizer = new Gpt3Tokenizer(new Gpt3TokenizerConfig());
return $tokenizer->count($text);
return count(Encoder::encode($text));
}

function pk_ajax_ai_ask()
Expand All @@ -33,10 +30,10 @@ function pk_ajax_ai_ask()
$openaiClient->setBaseURL($openai_url);
$sys_content = pk_get_option('openai_model_sys_content');
$messages = [];
$use_total_token = pk_ajax_openai_token_len($text);
$use_total_token = pk_openai_token_len($text);
if (!empty($sys_content)) {
$messages[] = ['role' => 'system', 'content' => $sys_content];
$use_total_token += pk_ajax_openai_token_len($sys_content);
$use_total_token += pk_openai_token_len($sys_content);
}
$messages[] = ['role' => 'user', 'content' => $text];
$max_tokens = pk_get_option('openai_max_tokens', 0);
Expand Down
2 changes: 1 addition & 1 deletion inc/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function pk_disable_emojis_tinymce($plugins)
function pk_env_check()
{
$php_version = phpversion();
$last_version = '8.0.2';
$last_version = '7.4';
$content = [];
if (version_compare($php_version, $last_version, '<')) {
$content[] = '<p>您正在使用过时的PHP版本<code>' . $php_version . '</code>,Puock主题需要PHP版本大于<code>' . $last_version . '</code>才能完整使用全部功能,请升级PHP版本。</p>';
Expand Down
2 changes: 1 addition & 1 deletion vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit4f6b69ae626959092fc09391096ba5a1::getLoader();
return ComposerAutoloaderInitf74d6302ff22d6ca9f1ebbf1a19d8e44::getLoader();
2 changes: 1 addition & 1 deletion vendor/composer/autoload_psr4.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
return array(
'Yurun\\Util\\' => array($vendorDir . '/yurunsoft/yurun-http/src'),
'Yurun\\OAuthLogin\\' => array($vendorDir . '/yurunsoft/yurun-oauth-login/src'),
'Rahul900day\\Gpt3Encoder\\' => array($vendorDir . '/rahul900day/gpt-3-encoder/src'),
'Puock\\Theme\\' => array($baseDir . '/inc'),
'Psr\\Log\\' => array($vendorDir . '/psr/log/src'),
'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src'),
'Orhanerday\\OpenAi\\' => array($vendorDir . '/orhanerday/open-ai/src'),
'Gioni06\\Gpt3Tokenizer\\' => array($vendorDir . '/gioni06/gpt3-tokenizer/src'),
);
10 changes: 4 additions & 6 deletions vendor/composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// autoload_real.php @generated by Composer

class ComposerAutoloaderInit4f6b69ae626959092fc09391096ba5a1
class ComposerAutoloaderInitf74d6302ff22d6ca9f1ebbf1a19d8e44
{
private static $loader;

Expand All @@ -22,14 +22,12 @@ public static function getLoader()
return self::$loader;
}

require __DIR__ . '/platform_check.php';

spl_autoload_register(array('ComposerAutoloaderInit4f6b69ae626959092fc09391096ba5a1', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitf74d6302ff22d6ca9f1ebbf1a19d8e44', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit4f6b69ae626959092fc09391096ba5a1', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitf74d6302ff22d6ca9f1ebbf1a19d8e44', 'loadClassLoader'));

require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit4f6b69ae626959092fc09391096ba5a1::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitf74d6302ff22d6ca9f1ebbf1a19d8e44::getInitializer($loader));

$loader->register(true);

Expand Down
24 changes: 12 additions & 12 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@

namespace Composer\Autoload;

class ComposerStaticInit4f6b69ae626959092fc09391096ba5a1
class ComposerStaticInitf74d6302ff22d6ca9f1ebbf1a19d8e44
{
public static $prefixLengthsPsr4 = array (
'Y' =>
array (
'Yurun\\Util\\' => 11,
'Yurun\\OAuthLogin\\' => 17,
),
'R' =>
array (
'Rahul900day\\Gpt3Encoder\\' => 24,
),
'P' =>
array (
'Puock\\Theme\\' => 12,
Expand All @@ -22,10 +26,6 @@ class ComposerStaticInit4f6b69ae626959092fc09391096ba5a1
array (
'Orhanerday\\OpenAi\\' => 18,
),
'G' =>
array (
'Gioni06\\Gpt3Tokenizer\\' => 22,
),
);

public static $prefixDirsPsr4 = array (
Expand All @@ -37,6 +37,10 @@ class ComposerStaticInit4f6b69ae626959092fc09391096ba5a1
array (
0 => __DIR__ . '/..' . '/yurunsoft/yurun-oauth-login/src',
),
'Rahul900day\\Gpt3Encoder\\' =>
array (
0 => __DIR__ . '/..' . '/rahul900day/gpt-3-encoder/src',
),
'Puock\\Theme\\' =>
array (
0 => __DIR__ . '/../..' . '/inc',
Expand All @@ -53,10 +57,6 @@ class ComposerStaticInit4f6b69ae626959092fc09391096ba5a1
array (
0 => __DIR__ . '/..' . '/orhanerday/open-ai/src',
),
'Gioni06\\Gpt3Tokenizer\\' =>
array (
0 => __DIR__ . '/..' . '/gioni06/gpt3-tokenizer/src',
),
);

public static $classMap = array (
Expand All @@ -68,9 +68,9 @@ class ComposerStaticInit4f6b69ae626959092fc09391096ba5a1
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit4f6b69ae626959092fc09391096ba5a1::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit4f6b69ae626959092fc09391096ba5a1::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit4f6b69ae626959092fc09391096ba5a1::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitf74d6302ff22d6ca9f1ebbf1a19d8e44::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitf74d6302ff22d6ca9f1ebbf1a19d8e44::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitf74d6302ff22d6ca9f1ebbf1a19d8e44::$classMap;

}, null, ClassLoader::class);
}
Expand Down

0 comments on commit 7883710

Please sign in to comment.