Skip to content

Commit 5cd68f6

Browse files
authored
Merge pull request #4 from zngly/bug/2/gallery
Bug/2/gallery
2 parents acda6fb + de0d123 commit 5cd68f6

File tree

11 files changed

+184
-21
lines changed

11 files changed

+184
-21
lines changed

.vscode/launch.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Listen for Xdebug",
9+
"type": "php",
10+
"request": "launch",
11+
"port": 9003
12+
}
13+
]
14+
}

composer.json

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.0.11",
2+
"version": "1.0.12",
33
"name": "zngly/wp-graphql-acf-mutations",
44
"description": "ACF Mutations for WP GraphQL",
55
"homepage": "https://github.com/zngly/wp-graphql-acf-mutations",
@@ -63,26 +63,19 @@
6363
"spatie/file-system-watcher": "^1.1"
6464
},
6565
"autoload-dev": {
66-
"psr-4": {
67-
"WPGraphQL\\ACF\\Mutations\\": "src/",
68-
"Zngly\\ACF\\Scripts\\": "scripts/",
69-
"\\": "wordpress/vendor/"
70-
},
7166
"classmap": [
72-
"src",
73-
"scripts",
74-
"wordpress/vendor"
67+
"src/",
68+
"scripts/",
69+
"dev/"
7570
]
7671
},
7772
"autoload": {
78-
"psr-4": {
79-
"WPGraphQL\\ACF\\Mutations\\": "src/"
80-
},
8173
"classmap": [
8274
"src/"
8375
]
8476
},
8577
"scripts": {
78+
"install": "composer install --no-dev",
8679
"install:dev": [
8780
"Zngly\\ACF\\Scripts\\Install::run"
8881
],

dev/acf/acf.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
// load acf configuration here

dev/index.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
namespace Zngly\ACF\Dev;
4+
5+
require_once __DIR__ . '/acf/acf.php';
6+
7+
class Init
8+
{
9+
10+
public static function run()
11+
{
12+
add_action('init', function () {
13+
Init::welcome_message();
14+
Init::plugins();
15+
});
16+
}
17+
18+
public static function welcome_message()
19+
{
20+
echo '<script>';
21+
echo 'console.log("Welcome to Zngly WP-Graphq-ACF-Mutations");';
22+
echo '</script>';
23+
}
24+
25+
public static function plugins()
26+
{
27+
// get all the activated plugins
28+
$active_plugins = get_option('active_plugins');
29+
30+
// get all the plugins
31+
$plugins = get_plugins();
32+
33+
// if a plugin is not activated, activate it
34+
foreach ($plugins as $plugin_path => $plugin)
35+
if (!in_array($plugin_path, $active_plugins))
36+
activate_plugin($plugin_path);
37+
}
38+
}

dev/query.graphql

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
mutation Content_Update_Mutation {
2+
updateZnglyVideo(
3+
input: {
4+
id: "cG9zdDo5OTA2Mjg="
5+
status: PENDING
6+
tags: { nodes: [{ name: "tag" }, { name: "two" }, { name: "three" }, { name: "test" }], append: false }
7+
}
8+
) {
9+
znglyVideo {
10+
title
11+
status
12+
tags {
13+
nodes {
14+
name
15+
}
16+
}
17+
}
18+
}
19+
}
20+
21+
query MyQuery5 {
22+
znglyVideos(where: { status: PENDING }) {
23+
nodes {
24+
title
25+
id
26+
tags {
27+
nodes {
28+
name
29+
}
30+
}
31+
}
32+
}
33+
}
34+
35+
query MyQuery2 {
36+
users(first: 100) {
37+
nodes {
38+
id
39+
databaseId
40+
username
41+
role
42+
}
43+
}
44+
}
45+
46+
query AuthorIn {
47+
znglyVideos(where: { author: 2 }) {
48+
nodes {
49+
title
50+
author {
51+
node {
52+
username
53+
databaseId
54+
id
55+
}
56+
}
57+
}
58+
}
59+
}
60+
61+
query setttings {
62+
znglyInfo(id: "site-info", idType: SLUG) {
63+
databaseId
64+
znglyInfo {
65+
address1
66+
address2
67+
address3
68+
}
69+
}
70+
}
71+
72+
mutation MyMutation2 {
73+
updateMediaItem(input: { id: "cG9zdDoxNzcw", coords: "testing" }) {
74+
mediaItem {
75+
id
76+
title
77+
fields {
78+
coords
79+
}
80+
}
81+
}
82+
}

dev/readme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
### Dev
2+
3+
This folder is only used when developing the project.
4+
5+
index.php - The Init class is loaded by an mu-plugin called zngly_autloader.php

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "wp-graphql-acf-mutations",
3-
"version": "1.0.11",
3+
"version": "1.0.12",
44
"description": "wp-graphql-acf-mutations",
55
"homepage": "https://github.com/zngly/wp-graphql-acf-mutations#readme",
66
"author": "Vlad-Anton Medves",

scripts/Install.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,20 @@ private function modify_wordpress()
5353
{
5454
self::print("Modifying Wordpress...\n");
5555

56+
// add autoload to wp-config
5657
$wordpress_dir = $this->root_dir . '/wordpress';
57-
$wp_config_path = $wordpress_dir . '/wp-config-sample.php';
58-
59-
Utils::add_to_file($wp_config_path, "if(!defined('ABSPATH'))", 'require ABSPATH . "vendor/autoload.php";');
58+
Utils::add_to_file($wordpress_dir . '/wp-config.php', "if(!defined('ABSPATH'))", 'require ABSPATH . "vendor/autoload.php";');
59+
60+
// load our dev code here
61+
// create a new file called zngly.php in the mu-plugins folder
62+
$zngly_path = Utils::format_path($wordpress_dir . '/wp-content/mu-plugins/zngly_autoloader.php');
63+
64+
// create the file
65+
$zngly_file = fopen($zngly_path, 'w');
66+
// write the contents
67+
fwrite($zngly_file, "<?php\n\nuse Zngly\ACF\Dev\Init;\nInit::run();\n\n");
68+
// close the file
69+
fclose($zngly_file);
6070

6171
// delete all themes except twentytwentytwo
6272
$themes_dir = $wordpress_dir . '/wp-content/themes';

scripts/Utils.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,20 @@ public static function copy_folder($src, $dest)
9494
closedir($dir);
9595
}
9696

97+
public static function regenerate_autoloader()
98+
{
99+
$root_dir = self::get_root_dir();
100+
101+
// execute composer dump-autoload -o
102+
$command = "cd {$root_dir} && composer dump-autoload -o";
103+
$output = exec($command);
104+
echo $output;
105+
}
106+
107+
public static function format_path(string $path)
108+
{
109+
return str_replace('\\', '/', $path);
110+
}
97111

98112
public static function get_root_dir()
99113
{

scripts/Watcher.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,26 @@ public static function run()
2121
$plugin_folder = Utils::get_root_dir() . "/wordpress/wp-content/plugins/{$plugin_name}";
2222

2323
// watch for any file changes in the directory
24-
self::watch_dirs([$src_folder, "{$plugin_folder}/{$plugin_name}.php"]);
24+
self::watch_dirs([$src_folder, "{$plugin_folder}/{$plugin_name}.php"]);
2525
}
2626

27-
28-
2927
// function to watch a directory for changes
3028
public static function watch_dirs(array $dirs)
3129
{
3230
$root_dir = Utils::get_root_dir();
33-
$plugins_folder = $root_dir . "/wordpress/wp-content/plugins/" . Utils::get_plugin_name();
31+
$plugins_folder = Utils::format_path($root_dir . "/wordpress/wp-content/plugins/" . Utils::get_plugin_name());
3432

3533
Watch::paths(...$dirs)
3634
->onAnyChange(function (string $type, string $path) use ($root_dir, $plugins_folder) {
35+
// format path forwardslashes
36+
$path = Utils::format_path($path);
37+
38+
// find the new path to the change
3739
$path_parts = explode($root_dir, $path);
3840
$new_path = $plugins_folder . $path_parts[1];
3941

42+
echo "{$type}: {$path}\n";
43+
4044
switch ($type) {
4145
case Watch::EVENT_TYPE_DIRECTORY_CREATED:
4246
mkdir($new_path, 0777, true);

0 commit comments

Comments
 (0)