Using Landau-Ginsburg-Devonshire approach and available experimental results we reconstruct the thermodynamic potential of the layered ferroelectric CuInP$_2$S$_6$ (CIPS), which is expected to be applicable a wide range of temperatures and applied pressures. The analysis of temperature dependences of the dielectric permittivity and lattice constants for different applied pressures unexpectedly reveals the critically important role of the nonlinear electrostriction in this material. With the nonlinear electrostriction included we calculated temperature and pressure phase diagrams and spontaneous polarization of bulk CIPS. Using the coefficients of the reconstructed four-well thermodynamic potential, we study the strain-induced phase transitions in thin epitaxial CIPS films, as well as the stress-induced phase transitions in CIPS nanoparticles, which shape varies from prolate needles to oblate disks. We reveal the strong influence of the mismatch strain, elastic stress and shape anisotropy on the polar properties and phase diagrams of nanoscale CIPS. Also, we derived analytical expressions, which allow the elastic control of the nanoscale CIPS polar properties. Hence obtained results can be of particular interest for the strain-engineering of nanoscale layered nanoferroelectrics.