Skip to content

Commit

Permalink
refactor: update prefixes and keys
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaucau committed Jan 6, 2024
1 parent 0ea1f37 commit 225210a
Show file tree
Hide file tree
Showing 18 changed files with 1,311 additions and 1,392 deletions.
2 changes: 1 addition & 1 deletion .phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array">
<element value="gpt-vision-img-alt-generator"/>
<element value="acpl-ai-alt-generator"/>
</property>
</properties>
</rule>
Expand Down
10 changes: 7 additions & 3 deletions .wp-env.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"phpVersion": "8.1",
"plugins": [
"."
]
"plugins": ["."],
"config": {
"WP_DEBUG": true,
"WP_DEBUG_DISPLAY": true,
"WP_DEBUG_LOG": true,
"SCRIPT_DEBUG": true
}
}
29 changes: 14 additions & 15 deletions plugin.php → acpl-ai-alt-generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* @wordpress-plugin
* Plugin Name: GPT Vision Alt Text Generator
* Plugin URI: https://github.com/android-com-pl/wp-gpt-vision-img-alt-generator
* Plugin URI: https://github.com/android-com-pl/wp-ai-alt-generator
* Description: Automatically generate alt text for images using OpenAI GPT Vision API.
* Version: 1.2.0
* Requires at least: 6.3
Expand All @@ -11,11 +11,10 @@
* Author URI: https://android.com.pl/
* License: GPL v3
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
* Text Domain: gpt-vision-img-alt-generator
* @package ACP\AiAltGenerator
* @package ACPL\AIAltGenerator
*/

namespace ACP\AiAltGenerator;
namespace ACPL\AIAltGenerator;

use WP_Error;

Expand All @@ -24,14 +23,14 @@
exit();
}

define( 'ACP_AI_ALT_PLUGIN_FILE', __FILE__ );
define( 'ACP_AI_ALT_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
define( 'ACP_AI_ALT_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'ACPL_AI_ALT_PLUGIN_FILE', __FILE__ );
define( 'ACPL_AI_ALT_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
define( 'ACPL_AI_ALT_PLUGIN_URL', plugin_dir_url( __FILE__ ) );

require __DIR__ . '/vendor/autoload.php';

class AltGeneratorPlugin {
public const OPTION_NAME = 'acp_ai_alt_generator';
public const OPTION_NAME = 'acpl_ai_alt_generator';

public function __construct() {
add_filter( 'wp_generate_attachment_metadata', [ AltGenerator::class, 'on_attachment_upload' ], 10, 3 );
Expand All @@ -58,10 +57,10 @@ public static function error_log( WP_Error $error ): WP_Error {
}

private function enqueue_script( string $file_name, array|bool $args = false ): void {
$asset_file = include ACP_AI_ALT_PLUGIN_PATH . "build/$file_name.asset.php";
$asset_file = include ACPL_AI_ALT_PLUGIN_PATH . "build/$file_name.asset.php";
$handle = "acp/ai-alt-generator/$file_name";
wp_enqueue_script( $handle, ACP_AI_ALT_PLUGIN_URL . "build/$file_name.js", $asset_file['dependencies'], $asset_file['version'], $args );
wp_set_script_translations( $handle, 'gpt-vision-img-alt-generator' );
wp_enqueue_script( $handle, ACPL_AI_ALT_PLUGIN_URL . "build/$file_name.js", $asset_file['dependencies'], $asset_file['version'], $args );
wp_set_script_translations( $handle, 'acpl-ai-alt-generator' );
}

private function enqueue_attachment_edit_page_script(): void {
Expand All @@ -73,17 +72,17 @@ private function enqueue_attachment_edit_page_script(): void {
}

public function plugin_row_meta( array $plugin_meta, string $plugin_file ): array {
if ( str_contains( $plugin_file, basename( ACP_AI_ALT_PLUGIN_FILE ) ) ) {
if ( str_contains( $plugin_file, basename( ACPL_AI_ALT_PLUGIN_FILE ) ) ) {
$plugin_meta[] = sprintf(
'<a href="%s">%s</a>',
admin_url( 'options-media.php#' . Admin::SETTINGS_SECTION_ID ),
__( 'Settings', 'gpt-vision-img-alt-generator' )
__( 'Settings', 'acpl-ai-alt-generator' )
);

$plugin_meta[] = sprintf(
'<a href="%s" target="_blank" rel="noopener noreferrer">%s</a>',
'https://github.com/android-com-pl/wp-gpt-vision-img-alt-generator?sponsor=1',
__( 'Support Development', 'gpt-vision-img-alt-generator' )
'https://github.com/android-com-pl/wp-ai-alt-generator?sponsor=1',
__( 'Support Development', 'acpl-ai-alt-generator' )
);
}

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "wordpress-plugin",
"autoload": {
"psr-4": {
"ACP\\AiAltGenerator\\": "includes/"
"ACPL\\AIAltGenerator\\": "includes/"
}
},
"minimum-stability": "dev",
Expand Down
117 changes: 85 additions & 32 deletions composer.lock

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

Loading

0 comments on commit 225210a

Please sign in to comment.