Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rest Api? #25

Open
ManigandanRaamanathan opened this issue Jun 15, 2018 · 8 comments
Open

Rest Api? #25

ManigandanRaamanathan opened this issue Jun 15, 2018 · 8 comments

Comments

@ManigandanRaamanathan
Copy link

could you please explain/add rest accessibility?

@leocaseiro
Copy link
Owner

Sorry, I'm not sure if I understand what you mean.

Do you want to implement this plugin within the WordPress Rest API?

@ManigandanRaamanathan
Copy link
Author

I wanted you to develop rest api feature in this plugin.

@leocaseiro
Copy link
Owner

leocaseiro commented Jun 18, 2018

Hi, it's related to #24 as we don't have any public api to insert easily, however, you can implement that using cop_insert() and cop_update();

@leocaseiro
Copy link
Owner

Something like so:

Insert

$row = array('label' => 'Lorem Ipsum', 'name' => 'lorem_ipsum', 'value' => 'Something here...');
cop_insert($row);

Update

$row = array('id' => 123,  'label' => 'Lorem Ipsum', 'name' => 'lorem_ipsum', 'value' => 'Something here...');
cop_update($row);

@ManigandanRaamanathan
Copy link
Author

Instead of inserting and updating. How to get a list of all custom options and values?

@leocaseiro
Copy link
Owner

$all = cop_get_options();

@ManigandanRaamanathan
Copy link
Author

So I required to use $all = cop_get_options () when creating my own rest api endpoints?

@rexfng
Copy link

rexfng commented Jul 24, 2018

Or you can just create a variable from the php side and pass it to JS

 
$dataToBePassed = array(
    'name' => get_custom('name');
);
wp_localize_script( 'the_js_file_you_want_this_variable_be', 
'whatever_variable_name_you_want', $datatoBePassed );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants