Okay, I’m an experienced developer, but not much of a PHP/WordPress developer.
I inherited a site (thanks marketing team!) that was built by a contractor. I’m trying to grok the whole thing.
I’ve been making decent progress, but I’m trying to figure out how a JSON file is being loaded that is the basis for a page with a collection of cards on it.
So the data is in a file called `dev_tools.json`.
The only place this file is mentioned anywhere in the code is in a file called TycoCLI.php (Tyco is the vendor here — don’t mean to call them out, or anything…)
In this file is a class called TycoCLI. There is a method in the class as follows (redacted for brevity…)
`public function import_devtools( array $args, $assoc_args ) {`
`$override = ! empty( $assoc_args[‘override’] );`
`$cache_file = sprintf( ‘%s/cve-import/dev_tools.json’, TEMPLATEPATH );`
`$devTools = [];`
`if ( file_exists( $cache_file ) ) {`
`$data = json_decode( file_get_contents( $cache_file ), true );`
`if ( is_array( $data[‘tools’] ) ) {`
`$devTools = $data[‘tools’];`
`}`
`}`
`if ( ! empty( $tool[‘slug’] ) ) {`
`// Insert the post into the database.`
`$tool[‘post_id’] = wp_insert_post( array(`
`’post_title’ => $tool[‘name’],`
`’post_name’ => $tool[‘slug’],`
`’post_status’ => ‘publish’,`
`’post_author’ => 1,`
`’post_type’ => ‘tool’,`
`) );`
`}`
`}`
The class appears to load the JSON data into the database. That’s fine, but when does this happen? Is this actually a manual process that happens?
I’m used to the notion of a JSON file being dynamic — add an item to the JSON file and it just appears in the website. But that doesn’t seem to be the case here.
I’m kind of figuring this out as I ask the question, but it seems nuts to me. Is this how things are done in the WordPress world, or is my site a bit….off?
Thanks in advance for your response. I’m always grateful to folks who help me on Reddit.
​
[ad_2]